I am trying to prevent the user from using any special symbols and also from having blank spaces without a character. When I try to put it on my FormGroup Validator I get an error saying 'Argument of type 'number' is not assignable to parameter of type 'string | RegExp''
this.houseForm = this.fb.group({
address: [
null,
[Validators.required, Validators.pattern(^[A-Za-z0-9 ]*[A-Za-z0-9][A-Za-z0-9 ]*)],
]
});
Validators.pattern(/^[A-Za-z0-9 ]*[A-Za-z0-9][A-Za-z0-9 ]*$/)
? – Wiktor StribiżewValidators.pattern
accepts both.Validators.pattern(/^[A-Za-z0-9 ]*[A-Za-z0-9][A-Za-z0-9 ]*$/)
=Validators.pattern("[A-Za-z0-9 ]*[A-Za-z0-9][A-Za-z0-9 ]*")
– Wiktor Stribiżew/
, which is the syntax for instantiating aRegExp
object), nor is it enclosed within quotes (which would make it a string literal). – chuckx