Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Allow to pass function to message option #76

@fnky

Description

@fnky

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.'
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions