Currently, the input field only accepts characters. If any other type of character is entered, an error will be thrown as shown in the code below. How can I update this logic to allow not only letters but also special characters like hyphens and apostrophes?
function NameValidate(control: FormControl) {
if (typeof control.value !== 'string' || !/^[a-zA-Z\s]+$/g.test(control.value)) {
return {
error: 'Only characters allowed'
};
} else {
return null;
}
}