К
Size: a a a
К
ЕУ
public static adminValidator(adminService: AdminUserService): AsyncValidatorFn | any {
return async (control: AbstractControl) => {
const username = control?.value;
let unique = await adminService.isUsernameUnique(username);
return !unique;
}
}
public static adminUserUniqueValidator(adminService: AdminUserService): AsyncValidatorFn {
return control => control.valueChanges
?.pipe(
debounceTime(300),
distinctUntilChanged(),
switchMap((value: string) => adminService.isUsernameUnique(value)),
map((unique: boolean) =>
unique ? null : {'usernameUniquenessViolated': true}
),
first());
}
M
public static adminValidator(adminService: AdminUserService): AsyncValidatorFn | any {
return async (control: AbstractControl) => {
const username = control?.value;
let unique = await adminService.isUsernameUnique(username);
return !unique;
}
}
public static adminUserUniqueValidator(adminService: AdminUserService): AsyncValidatorFn {
return control => control.valueChanges
?.pipe(
debounceTime(300),
distinctUntilChanged(),
switchMap((value: string) => adminService.isUsernameUnique(value)),
map((unique: boolean) =>
unique ? null : {'usernameUniquenessViolated': true}
),
first());
}
MP
ОК
VM
SP
addUserForm = new FormGroup({пытался сделать таким образом, но не получается:
companies: new FormArray([
new FormGroup({
companyName: new FormControl(),
contractNumber: new FormControl()
})
]),
emailAgreement: new FormControl(),
phoneNumberAgreement: new FormControl(),
profileInfo: new FormGroup({
email: new FormControl(),
firstName: new FormControl(),
patronymic: new FormControl(),
workPhone: new FormControl(),
workPhoneAdd: new FormControl(),
birthDate: new FormControl(),
surname: new FormControl(),
phone: new FormControl()
})
})
const addProfile = {
companies: [
{
companyName: this.addUserForm.value.companyName,
contractNumber: this.addUserForm.value.companies.contractNumber
}
],
emailAgreement: this.addUserForm.value.emailAgreement,
phoneNumberAgreement: this.addUserForm.value.phoneNumberAgreement,
profileId: null,
profileInfo: {
email: this.addUserForm.value.profileInfo.email,
firstName: this.addUserForm.value.profileInfo.firstName,
patronymic: this.addUserForm.value.profileInfo.patronymic,
workPhone: this.addUserForm.value.profileInfo.workPhone,
workPhoneAdd: this.addUserForm.value.profileInfo.workPhoneAdd,
birthDate: this.addUserForm.value.profileInfo.birthDate,
surname: this.addUserForm.value.profileInfo.surname,
phone: this.addUserForm.value.profileInfo.phone
}
};
VM
addUserForm = new FormGroup({пытался сделать таким образом, но не получается:
companies: new FormArray([
new FormGroup({
companyName: new FormControl(),
contractNumber: new FormControl()
})
]),
emailAgreement: new FormControl(),
phoneNumberAgreement: new FormControl(),
profileInfo: new FormGroup({
email: new FormControl(),
firstName: new FormControl(),
patronymic: new FormControl(),
workPhone: new FormControl(),
workPhoneAdd: new FormControl(),
birthDate: new FormControl(),
surname: new FormControl(),
phone: new FormControl()
})
})
const addProfile = {
companies: [
{
companyName: this.addUserForm.value.companyName,
contractNumber: this.addUserForm.value.companies.contractNumber
}
],
emailAgreement: this.addUserForm.value.emailAgreement,
phoneNumberAgreement: this.addUserForm.value.phoneNumberAgreement,
profileId: null,
profileInfo: {
email: this.addUserForm.value.profileInfo.email,
firstName: this.addUserForm.value.profileInfo.firstName,
patronymic: this.addUserForm.value.profileInfo.patronymic,
workPhone: this.addUserForm.value.profileInfo.workPhone,
workPhoneAdd: this.addUserForm.value.profileInfo.workPhoneAdd,
birthDate: this.addUserForm.value.profileInfo.birthDate,
surname: this.addUserForm.value.profileInfo.surname,
phone: this.addUserForm.value.profileInfo.phone
}
};
SP
M
M
S
ЕУ
VM
S
ЕУ
Р
VM
S
{ } as Candidate
?