Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to pass function to message option #76

fnky opened this issue Oct 8, 2015 · 1 comment

Allow to pass function to message option #76

fnky opened this issue Oct 8, 2015 · 1 comment


Copy link

@fnky fnky commented Oct 8, 2015

The message option is limited to strings, which makes it non-trivial to deal with arrays, objects, etc.

var acceptedValues = [
  { id: 1, name: 'Banana' },
  { id: 2, name: 'Apple' },
  { id: 2, name: 'Mango' }

// Fruit is chosen through select which uses ids for value attribute
var constraints = {
  fruit: {
    within: (o) { return }),
    message: function (id) {
      return '^No such fruit ' + getFruitById(id) + ' available.'
Copy link

@ansman ansman commented Oct 10, 2015

Interesting, this definitely seems to be in the spirit of validate.js!

@ansman ansman added the enhancement label Oct 10, 2015
@ansman ansman added this to the Next milestone Oct 10, 2015
@ansman ansman closed this in 4f5e210 Oct 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.