tgriesser / checkit

simple, flexible validations for node and the browser
MIT License
223 stars 53 forks source link

Unexpected validated object #72

Open bharley opened 8 years ago

bharley commented 8 years ago

If you're validating properties of an object inside of the object being validated, they don't come through to the final validation object even though they're being validated:

const checkit = new Checkit({
  title: 'required',
  'name.first': 'required',
  'name.last': 'required',
  age: ['required', 'numeric']
});

checkit.runSync({
  title: 'Janitor',
  name: {first: 'John'},
  age: 32
});
// [ { Error message: '1 invalid values', errors: { 'name.last': [Object] } }, null ]

checkit.runSync({
  title: 'Janitor',
  name: {first: 'John', last: 'Doe'},
  age: 32
});
// [ null, { title: 'Janitor', age: 32 } ]

Given that the name property is being validated, I would expect that it would be part of the output too.