import { Component, OnInit, ViewChild } from '@angular/core'
import { Notifier, ServerService } from '@app/core'
-import { FormReactive, FormValidatorService, InstanceValidatorsService } from '@app/shared/shared-forms'
+import {
+ BODY_VALIDATOR,
+ FROM_EMAIL_VALIDATOR,
+ FROM_NAME_VALIDATOR,
+ SUBJECT_VALIDATOR
+} from '@app/shared/form-validators/instance-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { InstanceService } from '@app/shared/shared-instance'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
constructor (
protected formValidatorService: FormValidatorService,
private modalService: NgbModal,
- private instanceValidatorsService: InstanceValidatorsService,
private instanceService: InstanceService,
private serverService: ServerService,
private notifier: Notifier
.subscribe(config => this.serverConfig = config)
this.buildForm({
- fromName: this.instanceValidatorsService.FROM_NAME,
- fromEmail: this.instanceValidatorsService.FROM_EMAIL,
- subject: this.instanceValidatorsService.SUBJECT,
- body: this.instanceValidatorsService.BODY
+ fromName: FROM_NAME_VALIDATOR,
+ fromEmail: FROM_EMAIL_VALIDATOR,
+ subject: SUBJECT_VALIDATOR,
+ body: BODY_VALIDATOR
})
}
import { Notifier } from '@app/core'
import { ServerService } from '@app/core/server/server.service'
import {
- CustomConfigValidatorsService,
- FormReactive,
- FormValidatorService,
- SelectOptionsItem,
- UserValidatorsService
-} from '@app/shared/shared-forms'
+ ADMIN_EMAIL_VALIDATOR,
+ CACHE_CAPTIONS_SIZE_VALIDATOR,
+ CACHE_PREVIEWS_SIZE_VALIDATOR,
+ INDEX_URL_VALIDATOR,
+ INSTANCE_NAME_VALIDATOR,
+ INSTANCE_SHORT_DESCRIPTION_VALIDATOR,
+ SEARCH_INDEX_URL_VALIDATOR,
+ SERVICES_TWITTER_USERNAME_VALIDATOR,
+ SIGNUP_LIMIT_VALIDATOR,
+ TRANSCODING_THREADS_VALIDATOR
+} from '@app/shared/form-validators/custom-config-validators'
+import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService, SelectOptionsItem } from '@app/shared/shared-forms'
import { NgbNav } from '@ng-bootstrap/ng-bootstrap'
import { CustomConfig, ServerConfig } from '@shared/models'
constructor (
private viewportScroller: ViewportScroller,
protected formValidatorService: FormValidatorService,
- private customConfigValidatorsService: CustomConfigValidatorsService,
- private userValidatorsService: UserValidatorsService,
private notifier: Notifier,
private configService: ConfigService,
private serverService: ServerService
const formGroupData: { [key in keyof CustomConfig ]: any } = {
instance: {
- name: this.customConfigValidatorsService.INSTANCE_NAME,
- shortDescription: this.customConfigValidatorsService.INSTANCE_SHORT_DESCRIPTION,
+ name: INSTANCE_NAME_VALIDATOR,
+ shortDescription: INSTANCE_SHORT_DESCRIPTION_VALIDATOR,
description: null,
isNSFW: false,
},
services: {
twitter: {
- username: this.customConfigValidatorsService.SERVICES_TWITTER_USERNAME,
+ username: SERVICES_TWITTER_USERNAME_VALIDATOR,
whitelisted: null
}
},
cache: {
previews: {
- size: this.customConfigValidatorsService.CACHE_PREVIEWS_SIZE
+ size: CACHE_PREVIEWS_SIZE_VALIDATOR
},
captions: {
- size: this.customConfigValidatorsService.CACHE_CAPTIONS_SIZE
+ size: CACHE_CAPTIONS_SIZE_VALIDATOR
}
},
signup: {
enabled: null,
- limit: this.customConfigValidatorsService.SIGNUP_LIMIT,
+ limit: SIGNUP_LIMIT_VALIDATOR,
requiresEmailVerification: null
},
import: {
}
},
admin: {
- email: this.customConfigValidatorsService.ADMIN_EMAIL
+ email: ADMIN_EMAIL_VALIDATOR
},
contactForm: {
enabled: null
},
user: {
- videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA,
- videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY
+ videoQuota: USER_VIDEO_QUOTA_VALIDATOR,
+ videoQuotaDaily: USER_VIDEO_QUOTA_DAILY_VALIDATOR
},
transcoding: {
enabled: null,
- threads: this.customConfigValidatorsService.TRANSCODING_THREADS,
+ threads: TRANSCODING_THREADS_VALIDATOR,
allowAdditionalExtensions: null,
allowAudioFiles: null,
resolutions: {},
},
autoFollowIndex: {
enabled: null,
- indexUrl: this.customConfigValidatorsService.INDEX_URL
+ indexUrl: INDEX_URL_VALIDATOR
}
}
},
},
searchIndex: {
enabled: null,
- url: this.customConfigValidatorsService.SEARCH_INDEX_URL,
+ url: SEARCH_INDEX_URL_VALIDATOR,
disableLocalSearch: null,
isDefaultSearch: null
}
import { Component, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute } from '@angular/router'
import { Notifier } from '@app/core'
-import { BuildFormArgument, FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { BuildFormArgument } from '@app/shared/form-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { PeerTubePlugin, RegisterServerSettingOptions } from '@shared/models'
import { PluginApiService } from '../shared/plugin-api.service'
import { ActivatedRoute, Router } from '@angular/router'
import { ConfigService } from '@app/+admin/config/shared/config.service'
import { AuthService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
-import { FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import {
+ USER_CHANNEL_NAME_VALIDATOR,
+ USER_EMAIL_VALIDATOR,
+ USER_PASSWORD_OPTIONAL_VALIDATOR,
+ USER_PASSWORD_VALIDATOR,
+ USER_ROLE_VALIDATOR,
+ USER_USERNAME_VALIDATOR,
+ USER_VIDEO_QUOTA_DAILY_VALIDATOR,
+ USER_VIDEO_QUOTA_VALIDATOR
+} from '@app/shared/form-validators/user-validators'
+import { FormValidatorService } from '@app/shared/shared-forms'
import { UserCreate, UserRole } from '@shared/models'
import { UserEdit } from './user-edit'
protected configService: ConfigService,
protected screenService: ScreenService,
protected auth: AuthService,
- private userValidatorsService: UserValidatorsService,
private route: ActivatedRoute,
private router: Router,
private notifier: Notifier,
}
this.buildForm({
- username: this.userValidatorsService.USER_USERNAME,
- channelName: this.userValidatorsService.USER_CHANNEL_NAME,
- email: this.userValidatorsService.USER_EMAIL,
- password: this.isPasswordOptional() ? this.userValidatorsService.USER_PASSWORD_OPTIONAL : this.userValidatorsService.USER_PASSWORD,
- role: this.userValidatorsService.USER_ROLE,
- videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA,
- videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY,
+ username: USER_USERNAME_VALIDATOR,
+ channelName: USER_CHANNEL_NAME_VALIDATOR,
+ email: USER_EMAIL_VALIDATOR,
+ password: this.isPasswordOptional() ? USER_PASSWORD_OPTIONAL_VALIDATOR : USER_PASSWORD_VALIDATOR,
+ role: USER_ROLE_VALIDATOR,
+ videoQuota: USER_VIDEO_QUOTA_VALIDATOR,
+ videoQuotaDaily: USER_VIDEO_QUOTA_DAILY_VALIDATOR,
byPassAutoBlock: null
}, defaultValues)
}
import { Component, Input, OnInit } from '@angular/core'
import { Notifier, UserService } from '@app/core'
-import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { UserUpdate } from '@shared/models'
@Component({
constructor (
protected formValidatorService: FormValidatorService,
- private userValidatorsService: UserValidatorsService,
private notifier: Notifier,
private userService: UserService
) {
ngOnInit () {
this.buildForm({
- password: this.userValidatorsService.USER_PASSWORD
+ password: USER_PASSWORD_VALIDATOR
})
}
import { ActivatedRoute, Router } from '@angular/router'
import { ConfigService } from '@app/+admin/config/shared/config.service'
import { AuthService, Notifier, ScreenService, ServerService, User, UserService } from '@app/core'
-import { FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import {
+ USER_EMAIL_VALIDATOR,
+ USER_ROLE_VALIDATOR,
+ USER_VIDEO_QUOTA_DAILY_VALIDATOR,
+ USER_VIDEO_QUOTA_VALIDATOR
+} from '@app/shared/form-validators/user-validators'
+import { FormValidatorService } from '@app/shared/shared-forms'
import { User as UserType, UserAdminFlag, UserRole, UserUpdate } from '@shared/models'
import { UserEdit } from './user-edit'
protected configService: ConfigService,
protected screenService: ScreenService,
protected auth: AuthService,
- private userValidatorsService: UserValidatorsService,
private route: ActivatedRoute,
private router: Router,
private notifier: Notifier,
}
this.buildForm({
- email: this.userValidatorsService.USER_EMAIL,
- role: this.userValidatorsService.USER_ROLE,
- videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA,
- videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY,
+ email: USER_EMAIL_VALIDATOR,
+ role: USER_ROLE_VALIDATOR,
+ videoQuota: USER_VIDEO_QUOTA_VALIDATOR,
+ videoQuotaDaily: USER_VIDEO_QUOTA_DAILY_VALIDATOR,
byPassAutoBlock: null
}, defaultValues)
import { ActivatedRoute } from '@angular/router'
import { AuthService, Notifier, RedirectService, UserService } from '@app/core'
import { HooksService } from '@app/core/plugins/hooks.service'
-import { FormReactive, FormValidatorService, LoginValidatorsService } from '@app/shared/shared-forms'
+import { LOGIN_PASSWORD_VALIDATOR, LOGIN_USERNAME_VALIDATOR } from '@app/shared/form-validators/login-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
import { RegisteredExternalAuthConfig, ServerConfig } from '@shared/models'
protected formValidatorService: FormValidatorService,
private route: ActivatedRoute,
private modalService: NgbModal,
- private loginValidatorsService: LoginValidatorsService,
private authService: AuthService,
private userService: UserService,
private redirectService: RedirectService,
}
this.buildForm({
- username: this.loginValidatorsService.LOGIN_USERNAME,
- password: this.loginValidatorsService.LOGIN_PASSWORD
+ username: LOGIN_USERNAME_VALIDATOR,
+ password: LOGIN_PASSWORD_VALIDATOR
})
}
import { Component, OnInit } from '@angular/core'
import { Router } from '@angular/router'
import { AuthService, Notifier } from '@app/core'
-import { FormValidatorService, VideoChannelValidatorsService } from '@app/shared/shared-forms'
+import {
+ VIDEO_CHANNEL_DESCRIPTION_VALIDATOR,
+ VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
+ VIDEO_CHANNEL_NAME_VALIDATOR,
+ VIDEO_CHANNEL_SUPPORT_VALIDATOR
+} from '@app/shared/form-validators/video-channel-validators'
+import { FormValidatorService } from '@app/shared/shared-forms'
import { VideoChannelService } from '@app/shared/shared-main'
import { VideoChannelCreate } from '@shared/models'
import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
constructor (
protected formValidatorService: FormValidatorService,
private authService: AuthService,
- private videoChannelValidatorsService: VideoChannelValidatorsService,
private notifier: Notifier,
private router: Router,
private videoChannelService: VideoChannelService
ngOnInit () {
this.buildForm({
- name: this.videoChannelValidatorsService.VIDEO_CHANNEL_NAME,
- 'display-name': this.videoChannelValidatorsService.VIDEO_CHANNEL_DISPLAY_NAME,
- description: this.videoChannelValidatorsService.VIDEO_CHANNEL_DESCRIPTION,
- support: this.videoChannelValidatorsService.VIDEO_CHANNEL_SUPPORT
+ name: VIDEO_CHANNEL_NAME_VALIDATOR,
+ 'display-name': VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
+ description: VIDEO_CHANNEL_DESCRIPTION_VALIDATOR,
+ support: VIDEO_CHANNEL_SUPPORT_VALIDATOR
})
}
import { Component, OnDestroy, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { AuthService, Notifier, ServerService } from '@app/core'
-import { FormValidatorService, VideoChannelValidatorsService } from '@app/shared/shared-forms'
+import {
+ VIDEO_CHANNEL_DESCRIPTION_VALIDATOR,
+ VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
+ VIDEO_CHANNEL_SUPPORT_VALIDATOR
+} from '@app/shared/form-validators/video-channel-validators'
+import { FormValidatorService } from '@app/shared/shared-forms'
import { VideoChannel, VideoChannelService } from '@app/shared/shared-main'
import { ServerConfig, VideoChannelUpdate } from '@shared/models'
import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
constructor (
protected formValidatorService: FormValidatorService,
private authService: AuthService,
- private videoChannelValidatorsService: VideoChannelValidatorsService,
private notifier: Notifier,
private router: Router,
private route: ActivatedRoute,
.subscribe(config => this.serverConfig = config)
this.buildForm({
- 'display-name': this.videoChannelValidatorsService.VIDEO_CHANNEL_DISPLAY_NAME,
- description: this.videoChannelValidatorsService.VIDEO_CHANNEL_DESCRIPTION,
- support: this.videoChannelValidatorsService.VIDEO_CHANNEL_SUPPORT,
+ 'display-name': VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
+ description: VIDEO_CHANNEL_DESCRIPTION_VALIDATOR,
+ support: VIDEO_CHANNEL_SUPPORT_VALIDATOR,
bulkVideosSupportUpdate: null
})
import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
import { AuthService, Notifier } from '@app/core'
-import { FormReactive, FormValidatorService, VideoAcceptOwnershipValidatorsService } from '@app/shared/shared-forms'
+import { OWNERSHIP_CHANGE_CHANNEL_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { VideoChannelService, VideoOwnershipService } from '@app/shared/shared-main'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { VideoChangeOwnership, VideoChannel } from '@shared/models'
constructor (
protected formValidatorService: FormValidatorService,
- private videoChangeOwnershipValidatorsService: VideoAcceptOwnershipValidatorsService,
private videoOwnershipService: VideoOwnershipService,
private notifier: Notifier,
private authService: AuthService,
.subscribe(videoChannels => this.videoChannels = videoChannels.data)
this.buildForm({
- channel: this.videoChangeOwnershipValidatorsService.CHANNEL
+ channel: OWNERSHIP_CHANGE_CHANNEL_VALIDATOR
})
}
import { tap } from 'rxjs/operators'
import { Component, OnInit } from '@angular/core'
import { AuthService, ServerService, UserService } from '@app/core'
-import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import { USER_EMAIL_VALIDATOR, USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { User } from '@shared/models'
@Component({
constructor (
protected formValidatorService: FormValidatorService,
- private userValidatorsService: UserValidatorsService,
private authService: AuthService,
private userService: UserService,
private serverService: ServerService
- ) {
+ ) {
super()
}
ngOnInit () {
this.buildForm({
- 'new-email': this.userValidatorsService.USER_EMAIL,
- 'password': this.userValidatorsService.USER_PASSWORD
+ 'new-email': USER_EMAIL_VALIDATOR,
+ 'password': USER_PASSWORD_VALIDATOR
})
this.user = this.authService.getUser()
import { filter } from 'rxjs/operators'
import { Component, OnInit } from '@angular/core'
import { AuthService, Notifier, UserService } from '@app/core'
-import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import { USER_CONFIRM_PASSWORD_VALIDATOR, USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { User } from '@shared/models'
@Component({
constructor (
protected formValidatorService: FormValidatorService,
- private userValidatorsService: UserValidatorsService,
private notifier: Notifier,
private authService: AuthService,
private userService: UserService
ngOnInit () {
this.buildForm({
- 'current-password': this.userValidatorsService.USER_PASSWORD,
- 'new-password': this.userValidatorsService.USER_PASSWORD,
- 'new-confirmed-password': this.userValidatorsService.USER_CONFIRM_PASSWORD
+ 'current-password': USER_PASSWORD_VALIDATOR,
+ 'new-password': USER_PASSWORD_VALIDATOR,
+ 'new-confirmed-password': USER_CONFIRM_PASSWORD_VALIDATOR
})
this.user = this.authService.getUser()
import { Subject } from 'rxjs'
import { Component, Input, OnInit } from '@angular/core'
import { Notifier, User, UserService } from '@app/core'
-import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import { USER_DESCRIPTION_VALIDATOR, USER_DISPLAY_NAME_REQUIRED_VALIDATOR } from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
@Component({
selector: 'my-account-profile',
constructor (
protected formValidatorService: FormValidatorService,
- private userValidatorsService: UserValidatorsService,
private notifier: Notifier,
private userService: UserService
- ) {
+ ) {
super()
}
ngOnInit () {
this.buildForm({
- 'display-name': this.userValidatorsService.USER_DISPLAY_NAME_REQUIRED,
- description: this.userValidatorsService.USER_DESCRIPTION
+ 'display-name': USER_DISPLAY_NAME_REQUIRED_VALIDATOR,
+ description: USER_DESCRIPTION_VALIDATOR
})
this.userInformationLoaded.subscribe(() => {
import { Router } from '@angular/router'
import { AuthService, Notifier, ServerService } from '@app/core'
import { populateAsyncUserVideoChannels } from '@app/helpers'
-import { FormValidatorService, VideoPlaylistValidatorsService } from '@app/shared/shared-forms'
+import {
+ setPlaylistChannelValidator,
+ VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
+ VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR,
+ VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR,
+ VIDEO_PLAYLIST_PRIVACY_VALIDATOR
+} from '@app/shared/form-validators/video-playlist-validators'
+import { FormValidatorService } from '@app/shared/shared-forms'
import { VideoPlaylistService } from '@app/shared/shared-video-playlist'
import { VideoPlaylistCreate } from '@shared/models/videos/playlist/video-playlist-create.model'
import { VideoPlaylistPrivacy } from '@shared/models/videos/playlist/video-playlist-privacy.model'
constructor (
protected formValidatorService: FormValidatorService,
private authService: AuthService,
- private videoPlaylistValidatorsService: VideoPlaylistValidatorsService,
private notifier: Notifier,
private router: Router,
private videoPlaylistService: VideoPlaylistService,
ngOnInit () {
this.buildForm({
- displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME,
- privacy: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_PRIVACY,
- description: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DESCRIPTION,
- videoChannelId: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_CHANNEL_ID,
+ displayName: VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR,
+ privacy: VIDEO_PLAYLIST_PRIVACY_VALIDATOR,
+ description: VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR,
+ videoChannelId: VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
thumbnailfile: null
})
this.form.get('privacy').valueChanges.subscribe(privacy => {
- this.videoPlaylistValidatorsService.setChannelValidator(this.form.get('videoChannelId'), privacy)
+ setPlaylistChannelValidator(this.form.get('videoChannelId'), privacy)
})
populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
import { ActivatedRoute, Router } from '@angular/router'
import { AuthService, Notifier, ServerService } from '@app/core'
import { populateAsyncUserVideoChannels } from '@app/helpers'
-import { FormValidatorService, VideoPlaylistValidatorsService } from '@app/shared/shared-forms'
+import {
+ setPlaylistChannelValidator,
+ VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
+ VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR,
+ VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR,
+ VIDEO_PLAYLIST_PRIVACY_VALIDATOR
+} from '@app/shared/form-validators/video-playlist-validators'
+import { FormValidatorService } from '@app/shared/shared-forms'
import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
import { VideoPlaylistUpdate } from '@shared/models'
import { MyAccountVideoPlaylistEdit } from './my-account-video-playlist-edit'
constructor (
protected formValidatorService: FormValidatorService,
private authService: AuthService,
- private videoPlaylistValidatorsService: VideoPlaylistValidatorsService,
private notifier: Notifier,
private router: Router,
private route: ActivatedRoute,
ngOnInit () {
this.buildForm({
- displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME,
- privacy: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_PRIVACY,
- description: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DESCRIPTION,
- videoChannelId: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_CHANNEL_ID,
+ displayName: VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR,
+ privacy: VIDEO_PLAYLIST_PRIVACY_VALIDATOR,
+ description: VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR,
+ videoChannelId: VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,
thumbnailfile: null
})
this.form.get('privacy').valueChanges.subscribe(privacy => {
- this.videoPlaylistValidatorsService.setChannelValidator(this.form.get('videoChannelId'), privacy)
+ setPlaylistChannelValidator(this.form.get('videoChannelId'), privacy)
})
populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
import { Notifier, UserService } from '@app/core'
-import { FormReactive, FormValidatorService, VideoChangeOwnershipValidatorsService } from '@app/shared/shared-forms'
+import { OWNERSHIP_CHANGE_USERNAME_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { Video, VideoOwnershipService } from '@app/shared/shared-main'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
constructor (
protected formValidatorService: FormValidatorService,
- private videoChangeOwnershipValidatorsService: VideoChangeOwnershipValidatorsService,
private videoOwnershipService: VideoOwnershipService,
private notifier: Notifier,
private userService: UserService,
ngOnInit () {
this.buildForm({
- username: this.videoChangeOwnershipValidatorsService.USERNAME
+ username: OWNERSHIP_CHANGE_USERNAME_VALIDATOR
})
this.usernamePropositions = []
}
import { Component, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { Notifier, UserService } from '@app/core'
-import { FormReactive, FormValidatorService, ResetPasswordValidatorsService, UserValidatorsService } from '@app/shared/shared-forms'
+import { RESET_PASSWORD_CONFIRM_VALIDATOR } from '@app/shared/form-validators/reset-password-validators'
+import { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
@Component({
selector: 'my-login',
constructor (
protected formValidatorService: FormValidatorService,
- private resetPasswordValidatorsService: ResetPasswordValidatorsService,
- private userValidatorsService: UserValidatorsService,
private userService: UserService,
private notifier: Notifier,
private router: Router,
ngOnInit () {
this.buildForm({
- password: this.userValidatorsService.USER_PASSWORD,
- 'password-confirm': this.resetPasswordValidatorsService.RESET_PASSWORD_CONFIRM
+ password: USER_PASSWORD_VALIDATOR,
+ 'password-confirm': RESET_PASSWORD_CONFIRM_VALIDATOR
})
this.userId = this.route.snapshot.queryParams['userId']
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
import { FormGroup } from '@angular/forms'
import { UserService } from '@app/core'
-import { FormReactive, FormValidatorService, VideoChannelValidatorsService } from '@app/shared/shared-forms'
+import { VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR, VIDEO_CHANNEL_NAME_VALIDATOR } from '@app/shared/form-validators/video-channel-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
@Component({
selector: 'my-register-step-channel',
constructor (
protected formValidatorService: FormValidatorService,
- private userService: UserService,
- private videoChannelValidatorsService: VideoChannelValidatorsService
+ private userService: UserService
) {
super()
}
ngOnInit () {
this.buildForm({
- displayName: this.videoChannelValidatorsService.VIDEO_CHANNEL_DISPLAY_NAME,
- name: this.videoChannelValidatorsService.VIDEO_CHANNEL_NAME
+ displayName: VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR,
+ name: VIDEO_CHANNEL_NAME_VALIDATOR
})
setTimeout(() => this.formBuilt.emit(this.form))
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
import { FormGroup } from '@angular/forms'
import { UserService } from '@app/core'
-import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import {
+ USER_DISPLAY_NAME_REQUIRED_VALIDATOR,
+ USER_EMAIL_VALIDATOR,
+ USER_PASSWORD_VALIDATOR,
+ USER_TERMS_VALIDATOR,
+ USER_USERNAME_VALIDATOR
+} from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
@Component({
selector: 'my-register-step-user',
constructor (
protected formValidatorService: FormValidatorService,
- private userService: UserService,
- private userValidatorsService: UserValidatorsService
+ private userService: UserService
) {
super()
}
ngOnInit () {
this.buildForm({
- displayName: this.userValidatorsService.USER_DISPLAY_NAME_REQUIRED,
- username: this.userValidatorsService.USER_USERNAME,
- password: this.userValidatorsService.USER_PASSWORD,
- email: this.userValidatorsService.USER_EMAIL,
- terms: this.userValidatorsService.USER_TERMS
+ displayName: USER_DISPLAY_NAME_REQUIRED_VALIDATOR,
+ username: USER_USERNAME_VALIDATOR,
+ password: USER_PASSWORD_VALIDATOR,
+ email: USER_EMAIL_VALIDATOR,
+ terms: USER_TERMS_VALIDATOR
})
setTimeout(() => this.formBuilt.emit(this.form))
import { Component, OnInit } from '@angular/core'
import { Notifier, RedirectService, ServerService, UserService } from '@app/core'
-import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import { USER_EMAIL_VALIDATOR } from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { ServerConfig } from '@shared/models'
@Component({
constructor (
protected formValidatorService: FormValidatorService,
- private userValidatorsService: UserValidatorsService,
private userService: UserService,
private serverService: ServerService,
private notifier: Notifier,
.subscribe(config => this.serverConfig = config)
this.buildForm({
- 'verify-email-email': this.userValidatorsService.USER_EMAIL
+ 'verify-email-email': USER_EMAIL_VALIDATOR
})
}
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
import { ServerService } from '@app/core'
-import { FormReactive, FormValidatorService, VideoCaptionsValidatorsService } from '@app/shared/shared-forms'
+import { VIDEO_CAPTION_FILE_VALIDATOR, VIDEO_CAPTION_LANGUAGE_VALIDATOR } from '@app/shared/form-validators/video-captions-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { VideoCaptionEdit } from '@app/shared/shared-main'
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
import { ServerConfig, VideoConstant } from '@shared/models'
constructor (
protected formValidatorService: FormValidatorService,
private modalService: NgbModal,
- private serverService: ServerService,
- private videoCaptionsValidatorsService: VideoCaptionsValidatorsService
+ private serverService: ServerService
) {
super()
}
.subscribe(languages => this.videoCaptionLanguages = languages)
this.buildForm({
- language: this.videoCaptionsValidatorsService.VIDEO_CAPTION_LANGUAGE,
- captionfile: this.videoCaptionsValidatorsService.VIDEO_CAPTION_FILE
+ language: VIDEO_CAPTION_LANGUAGE_VALIDATOR,
+ captionfile: VIDEO_CAPTION_FILE_VALIDATOR
})
}
import { FormArray, FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms'
import { ServerService } from '@app/core'
import { removeElementFromArray } from '@app/helpers'
-import { FormReactiveValidationMessages, FormValidatorService, SelectChannelItem, VideoValidatorsService } from '@app/shared/shared-forms'
+import {
+ VIDEO_CATEGORY_VALIDATOR,
+ VIDEO_CHANNEL_VALIDATOR,
+ VIDEO_DESCRIPTION_VALIDATOR,
+ VIDEO_LANGUAGE_VALIDATOR,
+ VIDEO_LICENCE_VALIDATOR,
+ VIDEO_NAME_VALIDATOR,
+ VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR,
+ VIDEO_PRIVACY_VALIDATOR,
+ VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR,
+ VIDEO_SUPPORT_VALIDATOR,
+ VIDEO_TAGS_ARRAY_VALIDATOR
+} from '@app/shared/form-validators/video-validators'
+import { FormReactiveValidationMessages, FormValidatorService, SelectChannelItem } from '@app/shared/shared-forms'
import { InstanceService } from '@app/shared/shared-instance'
import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main'
import { ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models'
constructor (
private formValidatorService: FormValidatorService,
- private videoValidatorsService: VideoValidatorsService,
private videoService: VideoService,
private serverService: ServerService,
private instanceService: InstanceService,
tags: []
}
const obj: any = {
- name: this.videoValidatorsService.VIDEO_NAME,
- privacy: this.videoValidatorsService.VIDEO_PRIVACY,
- channelId: this.videoValidatorsService.VIDEO_CHANNEL,
+ name: VIDEO_NAME_VALIDATOR,
+ privacy: VIDEO_PRIVACY_VALIDATOR,
+ channelId: VIDEO_CHANNEL_VALIDATOR,
nsfw: null,
commentsEnabled: null,
downloadEnabled: null,
waitTranscoding: null,
- category: this.videoValidatorsService.VIDEO_CATEGORY,
- licence: this.videoValidatorsService.VIDEO_LICENCE,
- language: this.videoValidatorsService.VIDEO_LANGUAGE,
- description: this.videoValidatorsService.VIDEO_DESCRIPTION,
- tags: this.videoValidatorsService.VIDEO_TAGS_ARRAY,
+ category: VIDEO_CATEGORY_VALIDATOR,
+ licence: VIDEO_LICENCE_VALIDATOR,
+ language: VIDEO_LANGUAGE_VALIDATOR,
+ description: VIDEO_DESCRIPTION_VALIDATOR,
+ tags: VIDEO_TAGS_ARRAY_VALIDATOR,
previewfile: null,
- support: this.videoValidatorsService.VIDEO_SUPPORT,
- schedulePublicationAt: this.videoValidatorsService.VIDEO_SCHEDULE_PUBLICATION_AT,
- originallyPublishedAt: this.videoValidatorsService.VIDEO_ORIGINALLY_PUBLISHED_AT
+ support: VIDEO_SUPPORT_VALIDATOR,
+ schedulePublicationAt: VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR,
+ originallyPublishedAt: VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR
}
this.formValidatorService.updateForm(
import { Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core'
import { Router } from '@angular/router'
import { Notifier, User } from '@app/core'
-import { FormReactive, FormValidatorService, VideoCommentValidatorsService } from '@app/shared/shared-forms'
+import { VIDEO_COMMENT_TEXT_VALIDATOR } from '@app/shared/form-validators/video-comment-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { Video } from '@app/shared/shared-main'
import { VideoComment, VideoCommentService } from '@app/shared/shared-video-comment'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
constructor (
protected formValidatorService: FormValidatorService,
- private videoCommentValidatorsService: VideoCommentValidatorsService,
private notifier: Notifier,
private videoCommentService: VideoCommentService,
private modalService: NgbModal,
ngOnInit () {
this.buildForm({
- text: this.videoCommentValidatorsService.VIDEO_COMMENT_TEXT
+ text: VIDEO_COMMENT_TEXT_VALIDATOR
})
if (this.user) {
--- /dev/null
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const ABUSE_REASON_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [Validators.required, Validators.minLength(2), Validators.maxLength(3000)],
+ MESSAGES: {
+ 'required': $localize`Report reason is required.`,
+ 'minlength': $localize`Report reason must be at least 2 characters long.`,
+ 'maxlength': $localize`Report reason cannot be more than 3000 characters long.`
+ }
+}
+
+export const ABUSE_MODERATION_COMMENT_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [Validators.required, Validators.minLength(2), Validators.maxLength(3000)],
+ MESSAGES: {
+ 'required': $localize`Moderation comment is required.`,
+ 'minlength': $localize`Moderation comment must be at least 2 characters long.`,
+ 'maxlength': $localize`Moderation comment cannot be more than 3000 characters long.`
+ }
+}
+
+export const ABUSE_MESSAGE_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [Validators.required, Validators.minLength(2), Validators.maxLength(3000)],
+ MESSAGES: {
+ 'required': $localize`Abuse message is required.`,
+ 'minlength': $localize`Abuse message must be at least 2 characters long.`,
+ 'maxlength': $localize`Abuse message cannot be more than 3000 characters long.`
+ }
+}
--- /dev/null
+import { AbstractControl, FormControl, ValidatorFn, Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+import { validateHost } from './host'
+
+export function getNotEmptyHosts (hosts: string) {
+ return hosts
+ .split('\n')
+ .filter((host: string) => host && host.length !== 0) // Eject empty hosts
+}
+
+const validDomains: ValidatorFn = (control: FormControl) => {
+ if (!control.value) return null
+
+ const newHostsErrors = []
+ const hosts = getNotEmptyHosts(control.value)
+
+ for (const host of hosts) {
+ if (validateHost(host) === false) {
+ newHostsErrors.push($localize`${host} is not valid`)
+ }
+ }
+
+ /* Is not valid. */
+ if (newHostsErrors.length !== 0) {
+ return {
+ 'validDomains': {
+ reason: 'invalid',
+ value: newHostsErrors.join('. ') + '.'
+ }
+ }
+ }
+
+ /* Is valid. */
+ return null
+}
+
+const isHostsUnique: ValidatorFn = (control: AbstractControl) => {
+ if (!control.value) return null
+
+ const hosts = getNotEmptyHosts(control.value)
+
+ if (hosts.every((host: string) => hosts.indexOf(host) === hosts.lastIndexOf(host))) {
+ return null
+ } else {
+ return {
+ 'uniqueDomains': {
+ reason: 'invalid'
+ }
+ }
+ }
+}
+
+export const DOMAINS_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [Validators.required, validDomains, isHostsUnique],
+ MESSAGES: {
+ 'required': $localize`Domain is required.`,
+ 'validDomains': $localize`Domains entered are invalid.`,
+ 'uniqueDomains': $localize`Domains entered contain duplicates.`
+ }
+}
--- /dev/null
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const INSTANCE_NAME_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [Validators.required],
+ MESSAGES: {
+ 'required': $localize`Instance name is required.`
+ }
+}
+
+export const INSTANCE_SHORT_DESCRIPTION_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [Validators.max(250)],
+ MESSAGES: {
+ 'max': $localize`Short description should not be longer than 250 characters.`
+ }
+}
+
+export const SERVICES_TWITTER_USERNAME_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [Validators.required],
+ MESSAGES: {
+ 'required': $localize`Twitter username is required.`
+ }
+}
+
+export const CACHE_PREVIEWS_SIZE_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [Validators.required, Validators.min(1), Validators.pattern('[0-9]+')],
+ MESSAGES: {
+ 'required': $localize`Previews cache size is required.`,
+ 'min': $localize`Previews cache size must be greater than 1.`,
+ 'pattern': $localize`Previews cache size must be a number.`
+ }
+}
+
+export const CACHE_CAPTIONS_SIZE_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [Validators.required, Validators.min(1), Validators.pattern('[0-9]+')],
+ MESSAGES: {
+ 'required': $localize`Captions cache size is required.`,
+ 'min': $localize`Captions cache size must be greater than 1.`,
+ 'pattern': $localize`Captions cache size must be a number.`
+ }
+}
+
+export const SIGNUP_LIMIT_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [Validators.required, Validators.min(-1), Validators.pattern('-?[0-9]+')],
+ MESSAGES: {
+ 'required': $localize`Signup limit is required.`,
+ 'min': $localize`Signup limit must be greater than 1.`,
+ 'pattern': $localize`Signup limit must be a number.`
+ }
+}
+
+export const ADMIN_EMAIL_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [Validators.required, Validators.email],
+ MESSAGES: {
+ 'required': $localize`Admin email is required.`,
+ 'email': $localize`Admin email must be valid.`
+ }
+}
+
+export const TRANSCODING_THREADS_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [Validators.required, Validators.min(0)],
+ MESSAGES: {
+ 'required': $localize`Transcoding threads is required.`,
+ 'min': $localize`Transcoding threads must be greater or equal to 0.`
+ }
+}
+
+export const INDEX_URL_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [Validators.pattern(/^https:\/\//)],
+ MESSAGES: {
+ 'pattern': $localize`Index URL should be a URL`
+ }
+}
+
+export const SEARCH_INDEX_URL_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [Validators.pattern(/^https?:\/\//)],
+ MESSAGES: {
+ 'pattern': $localize`Search index URL should be a URL`
+ }
+}
--- /dev/null
+import { ValidatorFn } from '@angular/forms'
+
+export type BuildFormValidator = {
+ VALIDATORS: ValidatorFn[],
+ MESSAGES: { [ name: string ]: string }
+}
+
+export type BuildFormArgument = {
+ [ id: string ]: BuildFormValidator | BuildFormArgument
+}
+
+export type BuildFormDefaultValues = {
+ [ name: string ]: string | string[] | BuildFormDefaultValues
+}
--- /dev/null
+export * from './form-validator.model'
+export * from './host'
+
+// Don't re export const variables because webpack 4 cannot do tree shaking with them
+// export * from './abuse-validators'
+// export * from './batch-domains-validators'
+// export * from './custom-config-validators'
+// export * from './instance-validators'
+// export * from './login-validators'
+// export * from './reset-password-validators'
+// export * from './user-validators'
+// export * from './video-block-validators'
+// export * from './video-captions-validators'
+// export * from './video-channel-validators'
+// export * from './video-comment-validators'
+// export * from './video-playlist-validators'
+// export * from './video-validators'
--- /dev/null
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const FROM_EMAIL_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [Validators.required, Validators.email],
+ MESSAGES: {
+ 'required': $localize`Email is required.`,
+ 'email': $localize`Email must be valid.`
+ }
+}
+
+export const FROM_NAME_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.required,
+ Validators.minLength(1),
+ Validators.maxLength(120)
+ ],
+ MESSAGES: {
+ 'required': $localize`Your name is required.`,
+ 'minlength': $localize`Your name must be at least 1 character long.`,
+ 'maxlength': $localize`Your name cannot be more than 120 characters long.`
+ }
+}
+
+export const SUBJECT_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.required,
+ Validators.minLength(1),
+ Validators.maxLength(120)
+ ],
+ MESSAGES: {
+ 'required': $localize`A subject is required.`,
+ 'minlength': $localize`The subject must be at least 1 character long.`,
+ 'maxlength': $localize`The subject cannot be more than 120 characters long.`
+ }
+}
+
+export const BODY_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.required,
+ Validators.minLength(3),
+ Validators.maxLength(5000)
+ ],
+ MESSAGES: {
+ 'required': $localize`A message is required.`,
+ 'minlength': $localize`The message must be at least 3 characters long.`,
+ 'maxlength': $localize`The message cannot be more than 5000 characters long.`
+ }
+}
--- /dev/null
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const LOGIN_USERNAME_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.required
+ ],
+ MESSAGES: {
+ 'required': $localize`Username is required.`
+ }
+}
+
+export const LOGIN_PASSWORD_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.required
+ ],
+ MESSAGES: {
+ 'required': $localize`Password is required.`
+ }
+}
--- /dev/null
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const RESET_PASSWORD_CONFIRM_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.required
+ ],
+ MESSAGES: {
+ 'required': $localize`Confirmation of the password is required.`
+ }
+}
--- /dev/null
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const USER_USERNAME_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.required,
+ Validators.minLength(1),
+ Validators.maxLength(50),
+ Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
+ ],
+ MESSAGES: {
+ 'required': $localize`Username is required.`,
+ 'minlength': $localize`Username must be at least 1 character long.`,
+ 'maxlength': $localize`Username cannot be more than 50 characters long.`,
+ 'pattern': $localize`Username should be lowercase alphanumeric; dots and underscores are allowed.`
+ }
+}
+
+export const USER_CHANNEL_NAME_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.required,
+ Validators.minLength(1),
+ Validators.maxLength(50),
+ Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
+ ],
+ MESSAGES: {
+ 'required': $localize`Channel name is required.`,
+ 'minlength': $localize`Channel name must be at least 1 character long.`,
+ 'maxlength': $localize`Channel name cannot be more than 50 characters long.`,
+ 'pattern': $localize`Channel name should be lowercase alphanumeric; dots and underscores are allowed.`
+ }
+}
+
+export const USER_EMAIL_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.required, Validators.email ],
+ MESSAGES: {
+ 'required': $localize`Email is required.`,
+ 'email': $localize`Email must be valid.`
+ }
+}
+
+export const USER_PASSWORD_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.required,
+ Validators.minLength(6),
+ Validators.maxLength(255)
+ ],
+ MESSAGES: {
+ 'required': $localize`Password is required.`,
+ 'minlength': $localize`Password must be at least 6 characters long.`,
+ 'maxlength': $localize`Password cannot be more than 255 characters long.`
+ }
+}
+
+export const USER_PASSWORD_OPTIONAL_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.minLength(6),
+ Validators.maxLength(255)
+ ],
+ MESSAGES: {
+ 'minlength': $localize`Password must be at least 6 characters long.`,
+ 'maxlength': $localize`Password cannot be more than 255 characters long.`
+ }
+}
+
+export const USER_CONFIRM_PASSWORD_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [],
+ MESSAGES: {
+ 'matchPassword': $localize`The new password and the confirmed password do not correspond.`
+ }
+}
+
+export const USER_VIDEO_QUOTA_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.required, Validators.min(-1) ],
+ MESSAGES: {
+ 'required': $localize`Video quota is required.`,
+ 'min': $localize`Quota must be greater than -1.`
+ }
+}
+export const USER_VIDEO_QUOTA_DAILY_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.required, Validators.min(-1) ],
+ MESSAGES: {
+ 'required': $localize`Daily upload limit is required.`,
+ 'min': $localize`Daily upload limit must be greater than -1.`
+ }
+}
+
+export const USER_ROLE_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.required ],
+ MESSAGES: {
+ 'required': $localize`User role is required.`
+ }
+}
+
+export const USER_DISPLAY_NAME_REQUIRED_VALIDATOR = buildDisplayNameValidator(true)
+
+export const USER_DESCRIPTION_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.minLength(3),
+ Validators.maxLength(1000)
+ ],
+ MESSAGES: {
+ 'minlength': $localize`Description must be at least 3 characters long.`,
+ 'maxlength': $localize`Description cannot be more than 1000 characters long.`
+ }
+}
+
+export const USER_TERMS_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.requiredTrue
+ ],
+ MESSAGES: {
+ 'required': $localize`You must agree with the instance terms in order to register on it.`
+ }
+}
+
+export const USER_BAN_REASON_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.minLength(3),
+ Validators.maxLength(250)
+ ],
+ MESSAGES: {
+ 'minlength': $localize`Ban reason must be at least 3 characters long.`,
+ 'maxlength': $localize`Ban reason cannot be more than 250 characters long.`
+ }
+}
+
+function buildDisplayNameValidator (required: boolean) {
+ const control = {
+ VALIDATORS: [
+ Validators.minLength(1),
+ Validators.maxLength(120)
+ ],
+ MESSAGES: {
+ 'required': $localize`Display name is required.`,
+ 'minlength': $localize`Display name must be at least 1 character long.`,
+ 'maxlength': $localize`Display name cannot be more than 50 characters long.`
+ }
+ }
+
+ if (required) control.VALIDATORS.push(Validators.required)
+
+ return control
+}
--- /dev/null
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const VIDEO_BLOCK_REASON_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.minLength(2), Validators.maxLength(300) ],
+ MESSAGES: {
+ 'minlength': $localize`Block reason must be at least 2 characters long.`,
+ 'maxlength': $localize`Block reason cannot be more than 300 characters long.`
+ }
+}
--- /dev/null
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const VIDEO_CAPTION_LANGUAGE_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.required ],
+ MESSAGES: {
+ 'required': $localize`Video caption language is required.`
+ }
+}
+
+export const VIDEO_CAPTION_FILE_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.required ],
+ MESSAGES: {
+ 'required': $localize`Video caption file is required.`
+ }
+}
--- /dev/null
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const VIDEO_CHANNEL_NAME_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.required,
+ Validators.minLength(1),
+ Validators.maxLength(50),
+ Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
+ ],
+ MESSAGES: {
+ 'required': $localize`Name is required.`,
+ 'minlength': $localize`Name must be at least 1 character long.`,
+ 'maxlength': $localize`Name cannot be more than 50 characters long.`,
+ 'pattern': $localize`Name should be lowercase alphanumeric; dots and underscores are allowed.`
+ }
+}
+
+export const VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.required,
+ Validators.minLength(1),
+ Validators.maxLength(50)
+ ],
+ MESSAGES: {
+ 'required': $localize`Display name is required.`,
+ 'minlength': $localize`Display name must be at least 1 character long.`,
+ 'maxlength': $localize`Display name cannot be more than 50 characters long.`
+ }
+}
+
+export const VIDEO_CHANNEL_DESCRIPTION_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.minLength(3),
+ Validators.maxLength(1000)
+ ],
+ MESSAGES: {
+ 'minlength': $localize`Description must be at least 3 characters long.`,
+ 'maxlength': $localize`Description cannot be more than 1000 characters long.`
+ }
+}
+
+export const VIDEO_CHANNEL_SUPPORT_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.minLength(3),
+ Validators.maxLength(1000)
+ ],
+ MESSAGES: {
+ 'minlength': $localize`Support text must be at least 3 characters long.`,
+ 'maxlength': $localize`Support text cannot be more than 1000 characters long`
+ }
+}
--- /dev/null
+import { Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const VIDEO_COMMENT_TEXT_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.required, Validators.minLength(1), Validators.maxLength(3000) ],
+ MESSAGES: {
+ 'required': $localize`Comment is required.`,
+ 'minlength': $localize`Comment must be at least 2 characters long.`,
+ 'maxlength': $localize`Comment cannot be more than 3000 characters long.`
+ }
+}
--- /dev/null
+import { AbstractControl, ValidationErrors, Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const OWNERSHIP_CHANGE_CHANNEL_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.required ],
+ MESSAGES: {
+ 'required': $localize`The channel is required.`
+ }
+}
+
+export const OWNERSHIP_CHANGE_USERNAME_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.required, localAccountValidator ],
+ MESSAGES: {
+ 'required': $localize`The username is required.`,
+ 'localAccountOnly': $localize`You can only transfer ownership to a local account`
+ }
+}
+
+function localAccountValidator (control: AbstractControl): ValidationErrors {
+ if (control.value.includes('@')) {
+ return { 'localAccountOnly': true }
+ }
+
+ return null
+}
--- /dev/null
+import { Validators, AbstractControl } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+import { VideoPlaylistPrivacy } from '@shared/models'
+
+export const VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.required,
+ Validators.minLength(1),
+ Validators.maxLength(120)
+ ],
+ MESSAGES: {
+ 'required': $localize`Display name is required.`,
+ 'minlength': $localize`Display name must be at least 1 character long.`,
+ 'maxlength': $localize`Display name cannot be more than 120 characters long.`
+ }
+}
+
+export const VIDEO_PLAYLIST_PRIVACY_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.required
+ ],
+ MESSAGES: {
+ 'required': $localize`Privacy is required.`
+ }
+}
+
+export const VIDEO_PLAYLIST_DESCRIPTION_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [
+ Validators.minLength(3),
+ Validators.maxLength(1000)
+ ],
+ MESSAGES: {
+ 'minlength': $localize`Description must be at least 3 characters long.`,
+ 'maxlength': $localize`Description cannot be more than 1000 characters long.`
+ }
+}
+
+export const VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [],
+ MESSAGES: {
+ 'required': $localize`The channel is required when the playlist is public.`
+ }
+}
+
+export function setPlaylistChannelValidator (channelControl: AbstractControl, privacy: VideoPlaylistPrivacy) {
+ if (privacy.toString() === VideoPlaylistPrivacy.PUBLIC.toString()) {
+ channelControl.setValidators([Validators.required])
+ } else {
+ channelControl.setValidators(null)
+ }
+
+ channelControl.markAsDirty()
+ channelControl.updateValueAndValidity()
+}
--- /dev/null
+import { AbstractControl, ValidationErrors, ValidatorFn, Validators } from '@angular/forms'
+import { BuildFormValidator } from './form-validator.model'
+
+export const VIDEO_NAME_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ],
+ MESSAGES: {
+ 'required': $localize`Video name is required.`,
+ 'minlength': $localize`Video name must be at least 3 characters long.`,
+ 'maxlength': $localize`Video name cannot be more than 120 characters long.`
+ }
+}
+
+export const VIDEO_PRIVACY_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.required ],
+ MESSAGES: {
+ 'required': $localize`Video privacy is required.`
+ }
+}
+
+export const VIDEO_CATEGORY_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ ],
+ MESSAGES: {}
+}
+
+export const VIDEO_LICENCE_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ ],
+ MESSAGES: {}
+}
+
+export const VIDEO_LANGUAGE_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ ],
+ MESSAGES: {}
+}
+
+export const VIDEO_IMAGE_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ ],
+ MESSAGES: {}
+}
+
+export const VIDEO_CHANNEL_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.required ],
+ MESSAGES: {
+ 'required': $localize`Video channel is required.`
+ }
+}
+
+export const VIDEO_DESCRIPTION_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ],
+ MESSAGES: {
+ 'minlength': $localize`Video description must be at least 3 characters long.`,
+ 'maxlength': $localize`Video description cannot be more than 10000 characters long.`
+ }
+}
+
+export const VIDEO_TAG_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.minLength(2), Validators.maxLength(30) ],
+ MESSAGES: {
+ 'minlength': $localize`A tag should be more than 2 characters long.`,
+ 'maxlength': $localize`A tag should be less than 30 characters long.`
+ }
+}
+
+export const VIDEO_TAGS_ARRAY_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.maxLength(5), arrayTagLengthValidator() ],
+ MESSAGES: {
+ 'maxlength': $localize`A maximum of 5 tags can be used on a video.`,
+ 'arrayTagLength': $localize`A tag should be more than 2, and less than 30 characters long.`
+ }
+}
+
+export const VIDEO_SUPPORT_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ Validators.minLength(3), Validators.maxLength(1000) ],
+ MESSAGES: {
+ 'minlength': $localize`Video support must be at least 3 characters long.`,
+ 'maxlength': $localize`Video support cannot be more than 1000 characters long.`
+ }
+}
+
+export const VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ ],
+ MESSAGES: {
+ 'required': $localize`A date is required to schedule video update.`
+ }
+}
+
+export const VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR: BuildFormValidator = {
+ VALIDATORS: [ ],
+ MESSAGES: {}
+}
+
+function arrayTagLengthValidator (min = 2, max = 30): ValidatorFn {
+ return (control: AbstractControl): ValidationErrors => {
+ const array = control.value as Array<string>
+
+ if (array.every(e => e.length > min && e.length < max)) {
+ return null
+ }
+
+ return { 'arrayTagLength': true }
+ }
+}
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
import { AuthService, HtmlRendererService, Notifier } from '@app/core'
-import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
import { AbuseMessage, UserAbuse } from '@shared/models'
+import { ABUSE_MESSAGE_VALIDATOR } from '../form-validators/abuse-validators'
import { AbuseService } from '../shared-moderation'
@Component({
constructor (
protected formValidatorService: FormValidatorService,
- private abuseValidatorsService: AbuseValidatorsService,
private modalService: NgbModal,
private htmlRenderer: HtmlRendererService,
private auth: AuthService,
ngOnInit () {
this.buildForm({
- message: this.abuseValidatorsService.ABUSE_MESSAGE
+ message: ABUSE_MESSAGE_VALIDATOR
})
}
import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
import { Notifier } from '@app/core'
-import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { AbuseService } from '@app/shared/shared-moderation'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
import { AdminAbuse } from '@shared/models'
+import { ABUSE_MODERATION_COMMENT_VALIDATOR } from '../form-validators/abuse-validators'
@Component({
selector: 'my-moderation-comment-modal',
protected formValidatorService: FormValidatorService,
private modalService: NgbModal,
private notifier: Notifier,
- private abuseService: AbuseService,
- private abuseValidatorsService: AbuseValidatorsService
+ private abuseService: AbuseService
) {
super()
}
ngOnInit () {
this.buildForm({
- moderationComment: this.abuseValidatorsService.ABUSE_MODERATION_COMMENT
+ moderationComment: ABUSE_MODERATION_COMMENT_VALIDATOR
})
}
import { FormGroup } from '@angular/forms'
-import { BuildFormArgument, BuildFormDefaultValues, FormValidatorService } from './form-validators'
+import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model'
+import { FormValidatorService } from './form-validator.service'
export type FormReactiveErrors = { [ id: string ]: string | FormReactiveErrors }
export type FormReactiveValidationMessages = {
-import { FormBuilder, FormControl, FormGroup, ValidatorFn } from '@angular/forms'
import { Injectable } from '@angular/core'
-import { FormReactiveErrors, FormReactiveValidationMessages } from '../form-reactive'
-
-export type BuildFormValidator = {
- VALIDATORS: ValidatorFn[],
- MESSAGES: { [ name: string ]: string }
-}
-export type BuildFormArgument = {
- [ id: string ]: BuildFormValidator | BuildFormArgument
-}
-export type BuildFormDefaultValues = {
- [ name: string ]: string | string[] | BuildFormDefaultValues
-}
+import { FormBuilder, FormControl, FormGroup, ValidatorFn } from '@angular/forms'
+import { BuildFormArgument, BuildFormDefaultValues } from '../form-validators/form-validator.model'
+import { FormReactiveErrors, FormReactiveValidationMessages } from './form-reactive'
@Injectable()
export class FormValidatorService {
+++ /dev/null
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class AbuseValidatorsService {
- readonly ABUSE_REASON: BuildFormValidator
- readonly ABUSE_MODERATION_COMMENT: BuildFormValidator
- readonly ABUSE_MESSAGE: BuildFormValidator
-
- constructor () {
- this.ABUSE_REASON = {
- VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ],
- MESSAGES: {
- 'required': $localize`Report reason is required.`,
- 'minlength': $localize`Report reason must be at least 2 characters long.`,
- 'maxlength': $localize`Report reason cannot be more than 3000 characters long.`
- }
- }
-
- this.ABUSE_MODERATION_COMMENT = {
- VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ],
- MESSAGES: {
- 'required': $localize`Moderation comment is required.`,
- 'minlength': $localize`Moderation comment must be at least 2 characters long.`,
- 'maxlength': $localize`Moderation comment cannot be more than 3000 characters long.`
- }
- }
-
- this.ABUSE_MESSAGE = {
- VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(3000) ],
- MESSAGES: {
- 'required': $localize`Abuse message is required.`,
- 'minlength': $localize`Abuse message must be at least 2 characters long.`,
- 'maxlength': $localize`Abuse message cannot be more than 3000 characters long.`
- }
- }
- }
-}
+++ /dev/null
-import { Injectable } from '@angular/core'
-import { ValidatorFn, Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-import { validateHost } from './host'
-
-@Injectable()
-export class BatchDomainsValidatorsService {
- readonly DOMAINS: BuildFormValidator
-
- constructor () {
- this.DOMAINS = {
- VALIDATORS: [ Validators.required, this.validDomains, this.isHostsUnique ],
- MESSAGES: {
- 'required': $localize`Domain is required.`,
- 'validDomains': $localize`Domains entered are invalid.`,
- 'uniqueDomains': $localize`Domains entered contain duplicates.`
- }
- }
- }
-
- getNotEmptyHosts (hosts: string) {
- return hosts
- .split('\n')
- .filter((host: string) => host && host.length !== 0) // Eject empty hosts
- }
-
- private validDomains: ValidatorFn = (control) => {
- if (!control.value) return null
-
- const newHostsErrors = []
- const hosts = this.getNotEmptyHosts(control.value)
-
- for (const host of hosts) {
- if (validateHost(host) === false) {
- newHostsErrors.push($localize`${host} is not valid`)
- }
- }
-
- /* Is not valid. */
- if (newHostsErrors.length !== 0) {
- return {
- 'validDomains': {
- reason: 'invalid',
- value: newHostsErrors.join('. ') + '.'
- }
- }
- }
-
- /* Is valid. */
- return null
- }
-
- private isHostsUnique: ValidatorFn = (control) => {
- if (!control.value) return null
-
- const hosts = this.getNotEmptyHosts(control.value)
-
- if (hosts.every((host: string) => hosts.indexOf(host) === hosts.lastIndexOf(host))) {
- return null
- } else {
- return {
- 'uniqueDomains': {
- reason: 'invalid'
- }
- }
- }
- }
-}
+++ /dev/null
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class CustomConfigValidatorsService {
- readonly INSTANCE_NAME: BuildFormValidator
- readonly INSTANCE_SHORT_DESCRIPTION: BuildFormValidator
- readonly SERVICES_TWITTER_USERNAME: BuildFormValidator
- readonly CACHE_PREVIEWS_SIZE: BuildFormValidator
- readonly CACHE_CAPTIONS_SIZE: BuildFormValidator
- readonly SIGNUP_LIMIT: BuildFormValidator
- readonly ADMIN_EMAIL: BuildFormValidator
- readonly TRANSCODING_THREADS: BuildFormValidator
- readonly INDEX_URL: BuildFormValidator
- readonly SEARCH_INDEX_URL: BuildFormValidator
-
- constructor () {
- this.INSTANCE_NAME = {
- VALIDATORS: [ Validators.required ],
- MESSAGES: {
- 'required': $localize`Instance name is required.`
- }
- }
-
- this.INSTANCE_SHORT_DESCRIPTION = {
- VALIDATORS: [ Validators.max(250) ],
- MESSAGES: {
- 'max': $localize`Short description should not be longer than 250 characters.`
- }
- }
-
- this.SERVICES_TWITTER_USERNAME = {
- VALIDATORS: [ Validators.required ],
- MESSAGES: {
- 'required': $localize`Twitter username is required.`
- }
- }
-
- this.CACHE_PREVIEWS_SIZE = {
- VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
- MESSAGES: {
- 'required': $localize`Previews cache size is required.`,
- 'min': $localize`Previews cache size must be greater than 1.`,
- 'pattern': $localize`Previews cache size must be a number.`
- }
- }
-
- this.CACHE_CAPTIONS_SIZE = {
- VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
- MESSAGES: {
- 'required': $localize`Captions cache size is required.`,
- 'min': $localize`Captions cache size must be greater than 1.`,
- 'pattern': $localize`Captions cache size must be a number.`
- }
- }
-
- this.SIGNUP_LIMIT = {
- VALIDATORS: [ Validators.required, Validators.min(-1), Validators.pattern('-?[0-9]+') ],
- MESSAGES: {
- 'required': $localize`Signup limit is required.`,
- 'min': $localize`Signup limit must be greater than 1.`,
- 'pattern': $localize`Signup limit must be a number.`
- }
- }
-
- this.ADMIN_EMAIL = {
- VALIDATORS: [ Validators.required, Validators.email ],
- MESSAGES: {
- 'required': $localize`Admin email is required.`,
- 'email': $localize`Admin email must be valid.`
- }
- }
-
- this.TRANSCODING_THREADS = {
- VALIDATORS: [ Validators.required, Validators.min(0) ],
- MESSAGES: {
- 'required': $localize`Transcoding threads is required.`,
- 'min': $localize`Transcoding threads must be greater or equal to 0.`
- }
- }
-
- this.INDEX_URL = {
- VALIDATORS: [ Validators.pattern(/^https:\/\//) ],
- MESSAGES: {
- 'pattern': $localize`Index URL should be a URL`
- }
- }
-
- this.SEARCH_INDEX_URL = {
- VALIDATORS: [ Validators.pattern(/^https?:\/\//) ],
- MESSAGES: {
- 'pattern': $localize`Search index URL should be a URL`
- }
- }
- }
-}
+++ /dev/null
-export * from './abuse-validators.service'
-export * from './batch-domains-validators.service'
-export * from './custom-config-validators.service'
-export * from './form-validator.service'
-export * from './host'
-export * from './instance-validators.service'
-export * from './login-validators.service'
-export * from './reset-password-validators.service'
-export * from './user-validators.service'
-export * from './video-accept-ownership-validators.service'
-export * from './video-block-validators.service'
-export * from './video-captions-validators.service'
-export * from './video-change-ownership-validators.service'
-export * from './video-channel-validators.service'
-export * from './video-comment-validators.service'
-export * from './video-playlist-validators.service'
-export * from './video-validators.service'
+++ /dev/null
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class InstanceValidatorsService {
- readonly FROM_EMAIL: BuildFormValidator
- readonly FROM_NAME: BuildFormValidator
- readonly SUBJECT: BuildFormValidator
- readonly BODY: BuildFormValidator
-
- constructor () {
-
- this.FROM_EMAIL = {
- VALIDATORS: [ Validators.required, Validators.email ],
- MESSAGES: {
- 'required': $localize`Email is required.`,
- 'email': $localize`Email must be valid.`
- }
- }
-
- this.FROM_NAME = {
- VALIDATORS: [
- Validators.required,
- Validators.minLength(1),
- Validators.maxLength(120)
- ],
- MESSAGES: {
- 'required': $localize`Your name is required.`,
- 'minlength': $localize`Your name must be at least 1 character long.`,
- 'maxlength': $localize`Your name cannot be more than 120 characters long.`
- }
- }
-
- this.SUBJECT = {
- VALIDATORS: [
- Validators.required,
- Validators.minLength(1),
- Validators.maxLength(120)
- ],
- MESSAGES: {
- 'required': $localize`A subject is required.`,
- 'minlength': $localize`The subject must be at least 1 character long.`,
- 'maxlength': $localize`The subject cannot be more than 120 characters long.`
- }
- }
-
- this.BODY = {
- VALIDATORS: [
- Validators.required,
- Validators.minLength(3),
- Validators.maxLength(5000)
- ],
- MESSAGES: {
- 'required': $localize`A message is required.`,
- 'minlength': $localize`The message must be at least 3 characters long.`,
- 'maxlength': $localize`The message cannot be more than 5000 characters long.`
- }
- }
- }
-}
+++ /dev/null
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class LoginValidatorsService {
- readonly LOGIN_USERNAME: BuildFormValidator
- readonly LOGIN_PASSWORD: BuildFormValidator
-
- constructor () {
- this.LOGIN_USERNAME = {
- VALIDATORS: [
- Validators.required
- ],
- MESSAGES: {
- 'required': $localize`Username is required.`
- }
- }
-
- this.LOGIN_PASSWORD = {
- VALIDATORS: [
- Validators.required
- ],
- MESSAGES: {
- 'required': $localize`Password is required.`
- }
- }
- }
-}
+++ /dev/null
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class ResetPasswordValidatorsService {
- readonly RESET_PASSWORD_CONFIRM: BuildFormValidator
-
- constructor () {
- this.RESET_PASSWORD_CONFIRM = {
- VALIDATORS: [
- Validators.required
- ],
- MESSAGES: {
- 'required': $localize`Confirmation of the password is required.`
- }
- }
- }
-}
+++ /dev/null
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class UserValidatorsService {
- readonly USER_USERNAME: BuildFormValidator
- readonly USER_CHANNEL_NAME: BuildFormValidator
- readonly USER_EMAIL: BuildFormValidator
- readonly USER_PASSWORD: BuildFormValidator
- readonly USER_PASSWORD_OPTIONAL: BuildFormValidator
- readonly USER_CONFIRM_PASSWORD: BuildFormValidator
- readonly USER_VIDEO_QUOTA: BuildFormValidator
- readonly USER_VIDEO_QUOTA_DAILY: BuildFormValidator
- readonly USER_ROLE: BuildFormValidator
- readonly USER_DISPLAY_NAME_REQUIRED: BuildFormValidator
- readonly USER_DESCRIPTION: BuildFormValidator
- readonly USER_TERMS: BuildFormValidator
-
- readonly USER_BAN_REASON: BuildFormValidator
-
- constructor () {
-
- this.USER_USERNAME = {
- VALIDATORS: [
- Validators.required,
- Validators.minLength(1),
- Validators.maxLength(50),
- Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
- ],
- MESSAGES: {
- 'required': $localize`Username is required.`,
- 'minlength': $localize`Username must be at least 1 character long.`,
- 'maxlength': $localize`Username cannot be more than 50 characters long.`,
- 'pattern': $localize`Username should be lowercase alphanumeric; dots and underscores are allowed.`
- }
- }
-
- this.USER_CHANNEL_NAME = {
- VALIDATORS: [
- Validators.required,
- Validators.minLength(1),
- Validators.maxLength(50),
- Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
- ],
- MESSAGES: {
- 'required': $localize`Channel name is required.`,
- 'minlength': $localize`Channel name must be at least 1 character long.`,
- 'maxlength': $localize`Channel name cannot be more than 50 characters long.`,
- 'pattern': $localize`Channel name should be lowercase alphanumeric; dots and underscores are allowed.`
- }
- }
-
- this.USER_EMAIL = {
- VALIDATORS: [ Validators.required, Validators.email ],
- MESSAGES: {
- 'required': $localize`Email is required.`,
- 'email': $localize`Email must be valid.`
- }
- }
-
- this.USER_PASSWORD = {
- VALIDATORS: [
- Validators.required,
- Validators.minLength(6),
- Validators.maxLength(255)
- ],
- MESSAGES: {
- 'required': $localize`Password is required.`,
- 'minlength': $localize`Password must be at least 6 characters long.`,
- 'maxlength': $localize`Password cannot be more than 255 characters long.`
- }
- }
-
- this.USER_PASSWORD_OPTIONAL = {
- VALIDATORS: [
- Validators.minLength(6),
- Validators.maxLength(255)
- ],
- MESSAGES: {
- 'minlength': $localize`Password must be at least 6 characters long.`,
- 'maxlength': $localize`Password cannot be more than 255 characters long.`
- }
- }
-
- this.USER_CONFIRM_PASSWORD = {
- VALIDATORS: [],
- MESSAGES: {
- 'matchPassword': $localize`The new password and the confirmed password do not correspond.`
- }
- }
-
- this.USER_VIDEO_QUOTA = {
- VALIDATORS: [ Validators.required, Validators.min(-1) ],
- MESSAGES: {
- 'required': $localize`Video quota is required.`,
- 'min': $localize`Quota must be greater than -1.`
- }
- }
- this.USER_VIDEO_QUOTA_DAILY = {
- VALIDATORS: [ Validators.required, Validators.min(-1) ],
- MESSAGES: {
- 'required': $localize`Daily upload limit is required.`,
- 'min': $localize`Daily upload limit must be greater than -1.`
- }
- }
-
- this.USER_ROLE = {
- VALIDATORS: [ Validators.required ],
- MESSAGES: {
- 'required': $localize`User role is required.`
- }
- }
-
- this.USER_DISPLAY_NAME_REQUIRED = this.getDisplayName(true)
-
- this.USER_DESCRIPTION = {
- VALIDATORS: [
- Validators.minLength(3),
- Validators.maxLength(1000)
- ],
- MESSAGES: {
- 'minlength': $localize`Description must be at least 3 characters long.`,
- 'maxlength': $localize`Description cannot be more than 1000 characters long.`
- }
- }
-
- this.USER_TERMS = {
- VALIDATORS: [
- Validators.requiredTrue
- ],
- MESSAGES: {
- 'required': $localize`You must agree with the instance terms in order to register on it.`
- }
- }
-
- this.USER_BAN_REASON = {
- VALIDATORS: [
- Validators.minLength(3),
- Validators.maxLength(250)
- ],
- MESSAGES: {
- 'minlength': $localize`Ban reason must be at least 3 characters long.`,
- 'maxlength': $localize`Ban reason cannot be more than 250 characters long.`
- }
- }
- }
-
- private getDisplayName (required: boolean) {
- const control = {
- VALIDATORS: [
- Validators.minLength(1),
- Validators.maxLength(120)
- ],
- MESSAGES: {
- 'required': $localize`Display name is required.`,
- 'minlength': $localize`Display name must be at least 1 character long.`,
- 'maxlength': $localize`Display name cannot be more than 50 characters long.`
- }
- }
-
- if (required) control.VALIDATORS.push(Validators.required)
-
- return control
- }
-}
+++ /dev/null
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class VideoAcceptOwnershipValidatorsService {
- readonly CHANNEL: BuildFormValidator
-
- constructor () {
- this.CHANNEL = {
- VALIDATORS: [ Validators.required ],
- MESSAGES: {
- 'required': $localize`The channel is required.`
- }
- }
- }
-}
+++ /dev/null
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class VideoBlockValidatorsService {
- readonly VIDEO_BLOCK_REASON: BuildFormValidator
-
- constructor () {
- this.VIDEO_BLOCK_REASON = {
- VALIDATORS: [ Validators.minLength(2), Validators.maxLength(300) ],
- MESSAGES: {
- 'minlength': $localize`Block reason must be at least 2 characters long.`,
- 'maxlength': $localize`Block reason cannot be more than 300 characters long.`
- }
- }
- }
-}
+++ /dev/null
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class VideoCaptionsValidatorsService {
- readonly VIDEO_CAPTION_LANGUAGE: BuildFormValidator
- readonly VIDEO_CAPTION_FILE: BuildFormValidator
-
- constructor () {
-
- this.VIDEO_CAPTION_LANGUAGE = {
- VALIDATORS: [ Validators.required ],
- MESSAGES: {
- 'required': $localize`Video caption language is required.`
- }
- }
-
- this.VIDEO_CAPTION_FILE = {
- VALIDATORS: [ Validators.required ],
- MESSAGES: {
- 'required': $localize`Video caption file is required.`
- }
- }
- }
-}
+++ /dev/null
-import { Injectable } from '@angular/core'
-import { AbstractControl, ValidationErrors, Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class VideoChangeOwnershipValidatorsService {
- readonly USERNAME: BuildFormValidator
-
- constructor () {
- this.USERNAME = {
- VALIDATORS: [ Validators.required, this.localAccountValidator ],
- MESSAGES: {
- 'required': $localize`The username is required.`,
- 'localAccountOnly': $localize`You can only transfer ownership to a local account`
- }
- }
- }
-
- localAccountValidator (control: AbstractControl): ValidationErrors {
- if (control.value.includes('@')) {
- return { 'localAccountOnly': true }
- }
-
- return null
- }
-}
+++ /dev/null
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class VideoChannelValidatorsService {
- readonly VIDEO_CHANNEL_NAME: BuildFormValidator
- readonly VIDEO_CHANNEL_DISPLAY_NAME: BuildFormValidator
- readonly VIDEO_CHANNEL_DESCRIPTION: BuildFormValidator
- readonly VIDEO_CHANNEL_SUPPORT: BuildFormValidator
-
- constructor () {
- this.VIDEO_CHANNEL_NAME = {
- VALIDATORS: [
- Validators.required,
- Validators.minLength(1),
- Validators.maxLength(50),
- Validators.pattern(/^[a-z0-9][a-z0-9._]*$/)
- ],
- MESSAGES: {
- 'required': $localize`Name is required.`,
- 'minlength': $localize`Name must be at least 1 character long.`,
- 'maxlength': $localize`Name cannot be more than 50 characters long.`,
- 'pattern': $localize`Name should be lowercase alphanumeric; dots and underscores are allowed.`
- }
- }
-
- this.VIDEO_CHANNEL_DISPLAY_NAME = {
- VALIDATORS: [
- Validators.required,
- Validators.minLength(1),
- Validators.maxLength(50)
- ],
- MESSAGES: {
- 'required': $localize`Display name is required.`,
- 'minlength': $localize`Display name must be at least 1 character long.`,
- 'maxlength': $localize`Display name cannot be more than 50 characters long.`
- }
- }
-
- this.VIDEO_CHANNEL_DESCRIPTION = {
- VALIDATORS: [
- Validators.minLength(3),
- Validators.maxLength(1000)
- ],
- MESSAGES: {
- 'minlength': $localize`Description must be at least 3 characters long.`,
- 'maxlength': $localize`Description cannot be more than 1000 characters long.`
- }
- }
-
- this.VIDEO_CHANNEL_SUPPORT = {
- VALIDATORS: [
- Validators.minLength(3),
- Validators.maxLength(1000)
- ],
- MESSAGES: {
- 'minlength': $localize`Support text must be at least 3 characters long.`,
- 'maxlength': $localize`Support text cannot be more than 1000 characters long`
- }
- }
- }
-}
+++ /dev/null
-import { Injectable } from '@angular/core'
-import { Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class VideoCommentValidatorsService {
- readonly VIDEO_COMMENT_TEXT: BuildFormValidator
-
- constructor () {
- this.VIDEO_COMMENT_TEXT = {
- VALIDATORS: [ Validators.required, Validators.minLength(1), Validators.maxLength(3000) ],
- MESSAGES: {
- 'required': $localize`Comment is required.`,
- 'minlength': $localize`Comment must be at least 2 characters long.`,
- 'maxlength': $localize`Comment cannot be more than 3000 characters long.`
- }
- }
- }
-}
+++ /dev/null
-import { Injectable } from '@angular/core'
-import { AbstractControl, Validators } from '@angular/forms'
-import { VideoPlaylistPrivacy } from '@shared/models'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class VideoPlaylistValidatorsService {
- readonly VIDEO_PLAYLIST_DISPLAY_NAME: BuildFormValidator
- readonly VIDEO_PLAYLIST_PRIVACY: BuildFormValidator
- readonly VIDEO_PLAYLIST_DESCRIPTION: BuildFormValidator
- readonly VIDEO_PLAYLIST_CHANNEL_ID: BuildFormValidator
-
- constructor () {
- this.VIDEO_PLAYLIST_DISPLAY_NAME = {
- VALIDATORS: [
- Validators.required,
- Validators.minLength(1),
- Validators.maxLength(120)
- ],
- MESSAGES: {
- 'required': $localize`Display name is required.`,
- 'minlength': $localize`Display name must be at least 1 character long.`,
- 'maxlength': $localize`Display name cannot be more than 120 characters long.`
- }
- }
-
- this.VIDEO_PLAYLIST_PRIVACY = {
- VALIDATORS: [
- Validators.required
- ],
- MESSAGES: {
- 'required': $localize`Privacy is required.`
- }
- }
-
- this.VIDEO_PLAYLIST_DESCRIPTION = {
- VALIDATORS: [
- Validators.minLength(3),
- Validators.maxLength(1000)
- ],
- MESSAGES: {
- 'minlength': $localize`Description must be at least 3 characters long.`,
- 'maxlength': $localize`Description cannot be more than 1000 characters long.`
- }
- }
-
- this.VIDEO_PLAYLIST_CHANNEL_ID = {
- VALIDATORS: [ ],
- MESSAGES: {
- 'required': $localize`The channel is required when the playlist is public.`
- }
- }
- }
-
- setChannelValidator (channelControl: AbstractControl, privacy: VideoPlaylistPrivacy) {
- if (privacy.toString() === VideoPlaylistPrivacy.PUBLIC.toString()) {
- channelControl.setValidators([ Validators.required ])
- } else {
- channelControl.setValidators(null)
- }
-
- channelControl.markAsDirty()
- channelControl.updateValueAndValidity()
- }
-}
+++ /dev/null
-import { Injectable } from '@angular/core'
-import { AbstractControl, ValidationErrors, ValidatorFn, Validators } from '@angular/forms'
-import { BuildFormValidator } from './form-validator.service'
-
-@Injectable()
-export class VideoValidatorsService {
- readonly VIDEO_NAME: BuildFormValidator
- readonly VIDEO_PRIVACY: BuildFormValidator
- readonly VIDEO_CATEGORY: BuildFormValidator
- readonly VIDEO_LICENCE: BuildFormValidator
- readonly VIDEO_LANGUAGE: BuildFormValidator
- readonly VIDEO_IMAGE: BuildFormValidator
- readonly VIDEO_CHANNEL: BuildFormValidator
- readonly VIDEO_DESCRIPTION: BuildFormValidator
- readonly VIDEO_TAGS_ARRAY: BuildFormValidator
- readonly VIDEO_TAG: BuildFormValidator
- readonly VIDEO_SUPPORT: BuildFormValidator
- readonly VIDEO_SCHEDULE_PUBLICATION_AT: BuildFormValidator
- readonly VIDEO_ORIGINALLY_PUBLISHED_AT: BuildFormValidator
-
- constructor () {
-
- this.VIDEO_NAME = {
- VALIDATORS: [ Validators.required, Validators.minLength(3), Validators.maxLength(120) ],
- MESSAGES: {
- 'required': $localize`Video name is required.`,
- 'minlength': $localize`Video name must be at least 3 characters long.`,
- 'maxlength': $localize`Video name cannot be more than 120 characters long.`
- }
- }
-
- this.VIDEO_PRIVACY = {
- VALIDATORS: [ Validators.required ],
- MESSAGES: {
- 'required': $localize`Video privacy is required.`
- }
- }
-
- this.VIDEO_CATEGORY = {
- VALIDATORS: [ ],
- MESSAGES: {}
- }
-
- this.VIDEO_LICENCE = {
- VALIDATORS: [ ],
- MESSAGES: {}
- }
-
- this.VIDEO_LANGUAGE = {
- VALIDATORS: [ ],
- MESSAGES: {}
- }
-
- this.VIDEO_IMAGE = {
- VALIDATORS: [ ],
- MESSAGES: {}
- }
-
- this.VIDEO_CHANNEL = {
- VALIDATORS: [ Validators.required ],
- MESSAGES: {
- 'required': $localize`Video channel is required.`
- }
- }
-
- this.VIDEO_DESCRIPTION = {
- VALIDATORS: [ Validators.minLength(3), Validators.maxLength(10000) ],
- MESSAGES: {
- 'minlength': $localize`Video description must be at least 3 characters long.`,
- 'maxlength': $localize`Video description cannot be more than 10000 characters long.`
- }
- }
-
- this.VIDEO_TAG = {
- VALIDATORS: [ Validators.minLength(2), Validators.maxLength(30) ],
- MESSAGES: {
- 'minlength': $localize`A tag should be more than 2 characters long.`,
- 'maxlength': $localize`A tag should be less than 30 characters long.`
- }
- }
-
- this.VIDEO_TAGS_ARRAY = {
- VALIDATORS: [ Validators.maxLength(5), this.arrayTagLengthValidator() ],
- MESSAGES: {
- 'maxlength': $localize`A maximum of 5 tags can be used on a video.`,
- 'arrayTagLength': $localize`A tag should be more than 2, and less than 30 characters long.`
- }
- }
-
- this.VIDEO_SUPPORT = {
- VALIDATORS: [ Validators.minLength(3), Validators.maxLength(1000) ],
- MESSAGES: {
- 'minlength': $localize`Video support must be at least 3 characters long.`,
- 'maxlength': $localize`Video support cannot be more than 1000 characters long.`
- }
- }
-
- this.VIDEO_SCHEDULE_PUBLICATION_AT = {
- VALIDATORS: [ ],
- MESSAGES: {
- 'required': $localize`A date is required to schedule video update.`
- }
- }
-
- this.VIDEO_ORIGINALLY_PUBLISHED_AT = {
- VALIDATORS: [ ],
- MESSAGES: {}
- }
- }
-
- arrayTagLengthValidator (min = 2, max = 30): ValidatorFn {
- return (control: AbstractControl): ValidationErrors => {
- const array = control.value as Array<string>
-
- if (array.every(e => e.length > min && e.length < max)) {
- return null
- }
-
- return { 'arrayTagLength': true }
- }
- }
-}
-export * from './form-validators'
+export * from './form-validator.service'
export * from './form-reactive'
export * from './select'
export * from './input-readonly-copy.component'
-import { NgModule } from '@angular/core'
-import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { InputMaskModule } from 'primeng/inputmask'
import { InputSwitchModule } from 'primeng/inputswitch'
+import { NgModule } from '@angular/core'
+import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { NgSelectModule } from '@ng-select/ng-select'
-import { BatchDomainsValidatorsService } from '@app/shared/shared-forms/form-validators/batch-domains-validators.service'
import { SharedGlobalIconModule } from '../shared-icons'
import { SharedMainModule } from '../shared-main/shared-main.module'
-import {
- CustomConfigValidatorsService,
- FormValidatorService,
- InstanceValidatorsService,
- LoginValidatorsService,
- ResetPasswordValidatorsService,
- UserValidatorsService,
- AbuseValidatorsService,
- VideoAcceptOwnershipValidatorsService,
- VideoBlockValidatorsService,
- VideoCaptionsValidatorsService,
- VideoChangeOwnershipValidatorsService,
- VideoChannelValidatorsService,
- VideoCommentValidatorsService,
- VideoPlaylistValidatorsService,
- VideoValidatorsService
-} from './form-validators'
+import { FormValidatorService } from './form-validator.service'
import { InputReadonlyCopyComponent } from './input-readonly-copy.component'
import { MarkdownTextareaComponent } from './markdown-textarea.component'
import { PeertubeCheckboxComponent } from './peertube-checkbox.component'
import { PreviewUploadComponent } from './preview-upload.component'
import { ReactiveFileComponent } from './reactive-file.component'
+import { SelectChannelComponent, SelectCheckboxComponent, SelectOptionsComponent, SelectTagsComponent } from './select'
import { TextareaAutoResizeDirective } from './textarea-autoresize.directive'
import { TimestampInputComponent } from './timestamp-input.component'
-import { SelectChannelComponent, SelectCheckboxComponent, SelectOptionsComponent, SelectTagsComponent } from './select'
@NgModule({
imports: [
],
providers: [
- CustomConfigValidatorsService,
- FormValidatorService,
- LoginValidatorsService,
- InstanceValidatorsService,
- LoginValidatorsService,
- ResetPasswordValidatorsService,
- UserValidatorsService,
- AbuseValidatorsService,
- VideoAcceptOwnershipValidatorsService,
- VideoBlockValidatorsService,
- VideoCaptionsValidatorsService,
- VideoChangeOwnershipValidatorsService,
- VideoChannelValidatorsService,
- VideoCommentValidatorsService,
- VideoPlaylistValidatorsService,
- VideoValidatorsService,
- BatchDomainsValidatorsService
+ FormValidatorService
]
})
export class SharedFormModule { }
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
-import { BatchDomainsValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
+import { DOMAINS_VALIDATOR, getNotEmptyHosts } from '../form-validators/batch-domains-validators'
@Component({
selector: 'my-batch-domains-modal',
constructor (
protected formValidatorService: FormValidatorService,
- private modalService: NgbModal,
- private batchDomainsValidatorsService: BatchDomainsValidatorsService
+ private modalService: NgbModal
) {
super()
}
if (!this.action) this.action = $localize`Process domains`
this.buildForm({
- domains: this.batchDomainsValidatorsService.DOMAINS
+ domains: DOMAINS_VALIDATOR
})
}
submit () {
this.domains.emit(
- this.batchDomainsValidatorsService.getNotEmptyHosts(this.form.controls['domains'].value)
+ getNotEmptyHosts(this.form.controls['domains'].value)
)
this.form.reset()
this.hide()
import { mapValues, pickBy } from 'lodash-es'
import { Component, Input, OnInit, ViewChild } from '@angular/core'
import { Notifier } from '@app/core'
-import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { Account } from '@app/shared/shared-main'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
constructor (
protected formValidatorService: FormValidatorService,
private modalService: NgbModal,
- private abuseValidatorsService: AbuseValidatorsService,
private abuseService: AbuseService,
private notifier: Notifier
) {
this.modalTitle = $localize`Report ${this.account.displayName}`
this.buildForm({
- reason: this.abuseValidatorsService.ABUSE_REASON,
+ reason: ABUSE_REASON_VALIDATOR,
predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null)
})
import { mapValues, pickBy } from 'lodash-es'
import { Component, Input, OnInit, ViewChild } from '@angular/core'
import { Notifier } from '@app/core'
-import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { VideoComment } from '@app/shared/shared-video-comment'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
constructor (
protected formValidatorService: FormValidatorService,
private modalService: NgbModal,
- private abuseValidatorsService: AbuseValidatorsService,
private abuseService: AbuseService,
private notifier: Notifier
) {
this.modalTitle = $localize`Report comment`
this.buildForm({
- reason: this.abuseValidatorsService.ABUSE_REASON,
+ reason: ABUSE_REASON_VALIDATOR,
predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null)
})
import { Component, Input, OnInit, ViewChild } from '@angular/core'
import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
import { Notifier } from '@app/core'
-import { AbuseValidatorsService, FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { ABUSE_REASON_VALIDATOR } from '@app/shared/form-validators/abuse-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
constructor (
protected formValidatorService: FormValidatorService,
private modalService: NgbModal,
- private abuseValidatorsService: AbuseValidatorsService,
private abuseService: AbuseService,
private notifier: Notifier,
private sanitizer: DomSanitizer
ngOnInit () {
this.buildForm({
- reason: this.abuseValidatorsService.ABUSE_REASON,
+ reason: ABUSE_REASON_VALIDATOR,
predefinedReasons: mapValues(abusePredefinedReasonsMap, r => null),
timestamp: {
hasStart: null,
import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
import { Notifier, UserService } from '@app/core'
-import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
import { User } from '@shared/models'
+import { USER_BAN_REASON_VALIDATOR } from '../form-validators/user-validators'
@Component({
selector: 'my-user-ban-modal',
protected formValidatorService: FormValidatorService,
private modalService: NgbModal,
private notifier: Notifier,
- private userService: UserService,
- private userValidatorsService: UserValidatorsService
+ private userService: UserService
) {
super()
}
ngOnInit () {
this.buildForm({
- reason: this.userValidatorsService.USER_BAN_REASON
+ reason: USER_BAN_REASON_VALIDATOR
})
}
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
import { Notifier } from '@app/core'
-import { FormReactive, FormValidatorService, VideoBlockValidatorsService } from '@app/shared/shared-forms'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { Video } from '@app/shared/shared-main'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
+import { VIDEO_BLOCK_REASON_VALIDATOR } from '../form-validators/video-block-validators'
import { VideoBlockService } from './video-block.service'
@Component({
constructor (
protected formValidatorService: FormValidatorService,
private modalService: NgbModal,
- private videoBlockValidatorsService: VideoBlockValidatorsService,
private videoBlocklistService: VideoBlockService,
private notifier: Notifier
) {
const defaultValues = { unfederate: 'true' }
this.buildForm({
- reason: this.videoBlockValidatorsService.VIDEO_BLOCK_REASON,
+ reason: VIDEO_BLOCK_REASON_VALIDATOR,
unfederate: null
}, defaultValues)
}
import { Component, Input, OnInit } from '@angular/core'
-import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
+import { USER_EMAIL_VALIDATOR } from '../form-validators/user-validators'
@Component({
selector: 'my-remote-subscribe',
@Input() showHelp = false
constructor (
- protected formValidatorService: FormValidatorService,
- private userValidatorsService: UserValidatorsService
+ protected formValidatorService: FormValidatorService
) {
super()
}
ngOnInit () {
this.buildForm({
- text: this.userValidatorsService.USER_EMAIL
+ text: USER_EMAIL_VALIDATOR
})
}
import { debounceTime, filter } from 'rxjs/operators'
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'
import { AuthService, DisableForReuseHook, Notifier } from '@app/core'
-import { FormReactive, FormValidatorService, VideoPlaylistValidatorsService } from '@app/shared/shared-forms'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { Video, VideoExistInPlaylist, VideoPlaylistCreate, VideoPlaylistElementCreate, VideoPlaylistPrivacy } from '@shared/models'
import { secondsToTime } from '../../../assets/player/utils'
+import { VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR } from '../form-validators/video-playlist-validators'
import { CachedPlaylist, VideoPlaylistService } from './video-playlist.service'
const logger = debug('peertube:playlists:VideoAddToPlaylistComponent')
private authService: AuthService,
private notifier: Notifier,
private videoPlaylistService: VideoPlaylistService,
- private videoPlaylistValidatorsService: VideoPlaylistValidatorsService,
private cd: ChangeDetectorRef
) {
super()
ngOnInit () {
this.buildForm({
- displayName: this.videoPlaylistValidatorsService.VIDEO_PLAYLIST_DISPLAY_NAME
+ displayName: VIDEO_PLAYLIST_DISPLAY_NAME_VALIDATOR
})
this.videoPlaylistService.listenToMyAccountPlaylistsChange()