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

Array of strings within a nested object fails validation #252

Closed pdinius closed 4 years ago

pdinius commented 4 years ago

This may be related to supporting (or not supporting) nested arrays but I wanted to validate/sanitize an object with a structure like this:

const data = {
  super: {
    sub: [
      'a', 'b', 'c'
    ]
  }
}

I would have thought from what I see in the documentation that it could be done like this:

const rules = {
  'super.sub.*': 'alpha'
}
validate(data, rules)
  .then( /**/ )
  .catch( /**/ );

But that returns an error, alpha validation failed on super.sub.0.super.::tip::. If the array is at the top of level and not within a nested object, it validates fine with a syntax like super.*. I thought based on documentation and other issues I read that this should be legal or at least not fail validation like this.

thetutlage commented 4 years ago

Yup, looks like a clear bug, will fix it :)

thetutlage commented 4 years ago

Actual bug fixed in https://github.com/poppinss/indicative-compiler/commit/ff4541db7352efa5a5c2c38795ad46eb61030622

thetutlage commented 4 years ago

Should be good with 7.2.2

pdinius commented 4 years ago

Awesome, thanks!