For reactive form validations i observed many tutorials and plunker links but i am not getting any site which solves my problem
problem 1: formgroup pattern is
[aA-zZ0-9'-]$/)](allow no, characters, -,', space special charactes)
export class AppComponent implements OnInit {
private myForm: FormGroup;
constructor(private fb: FormBuilder) {
}
ngOnInit() {
this.myForm = this.fb.group({
'name': ['', [Validators.required,
Validators.minLength(3),
Validators.maxLength(10),
Validators.pattern(/[aA-zZ0-9'-]$/)]],
'phoneNumbers': new FormArray([new FormControl('')])
});
}
}
for above that please check this plunker link
https://plnkr.co/edit/km7nGR8DjyE4l6tH5JEC?p=preview
Here if you observed name field it's working as per regular expression conditions in some cases
**case1-> aa -- not valid(minimum 3 characters),
case2-> aaa@ --not valid(special chararacter)
case3-> aaa@b -- valid(not giving any message)**
in above sceanarios case1, 2 is fine if you observe case3 input even it's not satisfiying regix rule it's not throwing any message
I am not sure that my regix is right, my requirment is (min-3, max-10, allow no, characters, -,', space special charactes)
I am trying so many types, but every where i am getting same problem
problem2: How to apply custom validator for form arrays
Please give me best approach which will sutes all general use cases
Thanks in advance
Soumya
^[A-Za-z0-9-' ]+$