Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createForms() {
// matching passwords validation
this.matching_passwords_group = new FormGroup({
password: new FormControl('', Validators.compose([
Validators.minLength(5),
Validators.required,
Validators.pattern('^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]+$')
])),
confirm_password: new FormControl('', Validators.required)
}, (formGroup: FormGroup) => {
return PasswordValidator.areEqual(formGroup);
});
// country & phone validation
let country = new FormControl(this.countries[0], Validators.required);
let phone = new FormControl('', {
validators: Validators.compose([
Validators.required,
PhoneValidator.validCountryPhone(country)
])
});
protected _initialForm() {
return this.fb.group({
'mediaType': [this.apiService.SEARCH_MEDIA_TYPE_MOVIE, Validators.required],
'sort_by': [this.DEFAULT_SORT, Validators.required],
'primary_release_date.gte': ['', Validators.pattern('\d{4}')],
'primary_release_date.lte': ['', Validators.pattern('\d{4}')],
'with_genres': ['', Validators.pattern('\d+')],
'page': [1, Validators.pattern('\d+')],
});
}
createFormControls() {
this.firstName = new FormControl('', Validators.required);
this.lastName = new FormControl('', Validators.required);
this.email = new FormControl('', [
Validators.required,
Validators.pattern("[^ @]*@[^ @]*"),
emailDomainValidator
]);
this.password = new FormControl('', [
Validators.required,
Validators.minLength(8)
]);
this.language = new FormControl('');
}
[
Validators.required,
Validators.minLength(6),
UserRegisterComponent.checkPassword.bind(this),
],
],
confirm: [
null,
[
Validators.required,
Validators.minLength(6),
UserRegisterComponent.passwordEquar,
],
],
mobilePrefix: ['+86'],
mobile: [null, [Validators.required, Validators.pattern(/^1\d{10}$/)]],
captcha: [null, [Validators.required]],
});
}
ups_mode_placeholder : T('UPS Mode'),
ups_mode_tooltip : T('Choose <i>Master</i> if the UPS is plugged directly\
into the system serial port. The UPS will remain the\
last item to shut down. Choose <i>Slave</i> to have\
this system shut down before <i>Master</i>. See the\
<a href="http://networkupstools.org/docs/user-manual.chunked/ar01s02.html#_monitoring_client">Network UPS Tools Overview</a>.'),
ups_mode_options : [
{label : 'Master', value : 'master'},
{label : 'Slave', value : 'slave'},
],
ups_identifier_placeholder : T('Identifier'),
ups_identifier_tooltip : T('Describe the UPS device. It can contain alphanumeric,\
period, comma, hyphen, and underscore characters.'),
ups_identifier_validation : [ Validators.required, Validators.pattern(/^[\w|,|\.|\-|_]+$/) ],
ups_remotehost_placeholder : T('Remote Host'),
ups_remotehost_tooltip : T('IP address of the remote system with <i>UPS Mode</i>\
set as <i>Master</i>. Enter a valid IP address in\
the format <i>192.168.0.1</i>.'),
ups_remotehost_validation : [ Validators.required ],
ups_remoteport_placeholder : T('Remote Port'),
ups_remoteport_tooltip : T(' When the <b>UPS Mode</b> is set to \
<i>slave</i>. Enter the open network port number of the UPS \
<i>Master</i> system. The default port is <i>3493</i>.'),
ups_remoteport_value : 3493,
ups_remoteport_validation : [ Validators.required ],
ups_driver_placeholder : T('Driver'),
ups_driver_tooltip : T('See the
private numberValidator(): ValidatorFn {
return Validators.pattern(/^\d+$/);
}
},
{
type : 'input',
name : 'username',
placeholder : T('Username'),
tooltip : T('Enter an alphanumeric username of eight to\
sixteen characters. Keeping usernames to eight\
characters or less is recommended for\
compatibility with legacy clients.\
Usernames cannot begin with a hyphen\
(<b>-</b>) or contain a space, tab, or these\
characters: <b>, : + & # %^ ( ) ! @ ~ * ? < > =</b>\
Note that <b>$</b> can only be used as the last\
character.'),
required: true,
validation : [ Validators.required, Validators.pattern('[a-z_A-Z_][a-zA-Z0-9_-]*[$]?'), Validators.maxLength(16) ],
blurStatus : true,
blurEvent: this.blurEvent2,
parent: this
},
{
type : 'input',
name : 'email',
placeholder : T('Email'),
tooltip : T('Enter the email address of the new user.'),
},
{
type : 'input',
name : 'password',
placeholder : T('Password'),
tooltip : T('Required unless <b>Enable password login</b> is\
<i>No</i>. Passwords cannot contain a <b>?</b>.'),
static requiredValidCountryIsoCode = Validators.compose([Validators.required, YcValidators.validCountryIsoCode]);
static validRole = Validators.pattern('ROLE_[A-Z_]+');
static requiredValidRole = Validators.compose([Validators.required, YcValidators.validRole]);
static positiveWholeNumber = Validators.pattern('[0-9]+');
static requiredPositiveWholeNumber = Validators.compose([Validators.required, YcValidators.positiveWholeNumber]);
static positiveNumber = Validators.pattern('[0-9]+(\\.[0-9]+)?');
static requiredPositiveNumber = Validators.compose([Validators.required, YcValidators.positiveNumber]);
static nonZeroPositiveNumber = Validators.pattern('[1-9][0-9]*(\\.[0-9]+)?');
static requiredNonZeroPositiveNumber = Validators.compose([Validators.required, YcValidators.nonZeroPositiveNumber]);
static rank = Validators.pattern('\\-?[0-9]+');
static requiredRank = Validators.compose([Validators.required, YcValidators.rank]);
static pk = Validators.pattern('[1-9][0-9]*');
static requiredPk = Validators.compose([Validators.required, YcValidators.pk]);
static validPhone = Validators.pattern('([+]){0,1}([()0-9- ]){5,}');
static validEmail = Validators.pattern('[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,8})');
static requiredValidEmail = Validators.compose([Validators.required, YcValidators.validEmail]);
private createEmptyForm(): void {
this.productForm = new FormGroup({
name: new FormControl('', Validators.required),
cost: new FormControl('', [Validators.required, Validators.pattern(regex.DOUBLE)]),
width: new FormControl('', Validators.pattern(regex.DOUBLE)),
height: new FormControl('', Validators.pattern(regex.DOUBLE)),
weight: new FormControl('', Validators.pattern(regex.DOUBLE)),
type: new FormControl(''),
details: new FormControl('', [Validators.pattern(regex.DETAILS)])
});
}