Closed FerrielMelarpis closed 6 years ago
indicative returns ENGINE_EXCEPTION error when using rule to construct range validation
ENGINE_EXCEPTION
rule
range
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)
rule('range', ['0', '5'])
if (Number.isNaN(Number(min)) || Number.isNan(Number(max))) { ...
Yup, mind creating a PR for same?
@thetutlage I submitted #185. I added some test cases to catch the issue. Please check if there's something wrong with my code. Thanks!
Fixed in related PR
Description
indicative returns
ENGINE_EXCEPTION
error when usingrule
to constructrange
validationCode for reproducing the issue
Investigation
rule('range', ['0', '5'])
works as expected since '0' is truthy.