I am trying to create a custom validator in angular 4 project which will only allow characters other than numbers to be typed.
So Far I have tried multiple options but none seem to work.
I am doing something like this:
Component
ngOnInit() {
  this.form = new FormGroup({
    ...
    city: new FormControl('', validateCity)
  });
}
Validator
import { FormControl } from '@angular/forms';
function validateCity(c: FormControl) {
  let CITY_REGEXP = /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]/i;
  return CITY_REGEXP.test(c.value) ? null : {
    validateCity: {
      valid: false
    }
  };
}
am I doing something wrong? thanks
 
     
    