Questions tagged «angular-validation»

8
预期验证者返回Promise或Observable
我正在尝试对Angular 5进行自定义验证,但遇到了以下错误 Expected validator to return Promise or Observable 我只想返回一个错误到表单,如果该值不符合要求,这是我的代码: 这是我的表格所在的组件 constructor(fb: FormBuilder, private cadastroService:CadastroService) { this.signUp = fb.group({ "name": ["", Validators.compose([Validators.required, Validators.minLength(2)])], "email": ["", Validators.compose([Validators.required, Validators.email])], "phone": ["", Validators.compose([Validators.required, Validators.minLength(5)])], "cpf": ["", Validators.required, ValidateCpf] }) } 这段代码在我要实现的验证文件中: import { AbstractControl } from '@angular/forms'; export function ValidateCpf(control: AbstractControl){ if (control.value …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.