poppinss / indicative

Indicative is a simple yet powerful data validator for Node.js and browsers. It makes it so simple to write async validations on nested set of data.
https://indicative.adonisjs.com/
MIT License
417 stars 52 forks source link

equals validation problem with numbers #69

Closed helnokaly closed 8 years ago

helnokaly commented 8 years ago

The equals validation fails with numbers because it compares Number with String (1 === '1')

data: {
  num: 1
}
rules: {
  num: 'integer|equals:1'
}
validation:  {
  "errors": [
    {
      "field": "num",
      "validation": "equals",
      "message": "equals validation failed on num"
    }
  ]
}
thetutlage commented 8 years ago

Sorry for the late reply have been busy lately. I will cast the value to a number before running the validation. Thanks for reporting.