79585461

Date: 2025-04-21 23:14:16
Score: 1
Natty:
Report link

You can simply do it with v.check:

const validValues = ['1', '2', '4'];

const Schema = v.object({
  // ...
  user: v.array(
    v.pipe(
      v.string(),
      v.regex(/^\d+$/, 'Invalid ID format'),
      v.check((item) => validValues.includes(item), 'ID is not allowed')
    )
  )
});
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: dimk_1