icebob / fastest-validator

:zap: The fastest JS validator library for NodeJS
MIT License
1.43k stars 89 forks source link

Strict for deep objects #315

Open zaksmok opened 1 year ago

zaksmok commented 1 year ago

Is it possible to set strict mode (yes/remove) to the deep objects somehow?

const schema = {
  $$strict: true,
  set: {
    type: 'object',
    props: {
      a: { type: 'number', min: 0, max: 1, optional: true },
      b: { type: 'number', min: 0, max: 1, optional: true },
    },
  },
  set2: {
    type: 'object',
    props: {
      a: { type: 'number', min: 0, max: 1, optional: true },
      b: { type: 'number', min: 0, max: 1, optional: true },
    },
  },
};

const payload = {
  set: {
    c: false,
    d: 'xxx',
  }
}
fernandodevelon commented 1 year ago

look at object documentation, you have the strict property https://github.com/icebob/fastest-validator#object