-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Closed
Labels
Description
Would it be possible to define rules like this:
email: {
identifier: 'email',
rules: [
{
type: 'empty',
prompt: options.messages.email_empty
},
{
type: 'email',
prompt: options.messages.email_invalid
},
{
type: 'checkRemoteValidity[email]',
prompt: foo
}
]
},
where foo
is a function called at validation time, which return a string, so when it validates it creates a customized prompt? Picture something like "The email [email protected] is already taken"
. Currently trying that fails with the error prompt.search is not a function
because of the line:
requiresValue = (prompt.search('{value}') !== -1),
so maybe in the previous line:
prompt = rule.prompt || settings.prompt[ruleName] || settings.text.unspecifiedRule,
we could try calling rule.prompt()? Would that work?