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

Range validation bug when using `rule` #184

Closed FerrielMelarpis closed 6 years ago

FerrielMelarpis commented 6 years ago

Description

indicative returns ENGINE_EXCEPTION error when using rule to construct range validation

Code for reproducing the issue

const {
    validate,
    rule
} = require('indicative');

const rules = {
    a: 'required',
    // this works
    // b: 'required|range:0,5'
    b: [
        rule('required'),
        rule('range', [0, 5])  // this doesn't work
    ]
};

const data = {
    a: 1,
    b: 1
};

validate(data, rules)
    .then(console.log)
    .catch(console.error)

Investigation

thetutlage commented 6 years ago

Yup, mind creating a PR for same?

FerrielMelarpis commented 6 years ago

@thetutlage I submitted #185. I added some test cases to catch the issue. Please check if there's something wrong with my code. Thanks!

thetutlage commented 6 years ago

Fixed in related PR