Skip to content

Adding domain validation to the "email" field

Adam Becker edited this page Aug 13, 2016 · 1 revision

Written for version 0.14.0

FormRenderer.t.errors.domain_invalid = 'Please enter an email ending in @dobt.co'

var oldValidate = FormRenderer.Validators.IdentificationValidator.validate;
FormRenderer.Validators.IdentificationValidator.validate = function(model) {
  var oldValidationResult = oldValidate.apply(this, arguments);
  if (oldValidationResult) return oldValidationResult;
  if (!model.get('value.email').match(/@dobt\.co$/)) {
    return 'domain_invalid';
  }
}