Closed ritchieanesco closed 4 years ago
Thanks. I've added this test to string
tests as email2.test.js
. Let's fix this issue next.
Just fixed this issue in latest master. See email2.test.js
See improved docs on error-messages
Now works with this config:
let config = {
errMessages: {
emailAdr: {
// note: would also work with email as the key
format: "emailAdr must be a valid email"
},
// generic fallback message for any email format validation
// note: if not present uses yup default validation message
$email: "Email format incorrect"
}
};
The main fix in mixed.js
:
valErrMessage(constraint) {
const { constraints } = this;
const errMsg = this.errMessageFor(constraint);
return typeof errMsg === "function" ? errMsg(constraints) : errMsg;
}
errMessageFor(msgName) {
const { errMessages, key } = this;
const errMsg = errMessages[key];
return errMsg ? errMsg[msgName] : errMessages[`$${msgName}`];
}
Ran the following test and the assertion failed.