fastest-validator icon indicating copy to clipboard operation
fastest-validator copied to clipboard

Strict for deep objects

Open zaksmok opened this issue 2 years ago • 1 comments

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',
  }
}

zaksmok avatar Jan 03 '23 10:01 zaksmok

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

fernandodevelon avatar Jul 10 '23 09:07 fernandodevelon