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

Closed
fnky opened this Issue Oct 8, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@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: acceptedValues.map(function (o) { return o.id }),
    message: function (id) {
      return '^No such fruit ' + getFruitById(id) + ' available.'
    }
  }
}
@ansman

This comment has been minimized.

Show comment
Hide comment
@ansman

ansman Oct 10, 2015

Owner

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

Owner

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