Open
Description
This bit of code:
tv4.addFormat("email", function (data, schema) {
if (typeof data === "string" && /^\S+@\S+$/.test(data)) {
return null;
}
return "A valid email address is required";
});
When applied like this:
email_address: {
title: "Email Address",
type: "string",
maxLength: 256,
format: "email"
}
Should result in the error:
A valid email address is required
Instead you get:
Format validation failed
From what I can tell the issue appears to be that the only portion of the errors generated by tv4 that are passed on are the error codes.
In src/directives/schema-validate.js:
ngModel.$setValidity('tv4-' + result.error.code, false);
For format validation using the above format rule, result.error.code
would be 500
and result.error.message
would be "Format validation failed (A valid email address is required)"
.
In schema-form, only the tv4 error code is used to select an error message which, of course, has no way of including the format error message returned by tv4.
src/services/errors.js
500: 'Format validation failed',