How to use the runtypes.Constraint function in runtypes

To help you get started, we’ve selected a few runtypes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github typeetfunc / runtypes-generate / src / custom.spec.ts View on Github external
const ArrayWithContains = (arrRt, item, count) => (args => Constraint(arrRt, list => {
  const res = contains(
    list, args,
    () => true,
    (_, res) => `Array contains less than ${res.needCount} items`,
    (_, res) => `Array contains more than ${res.needCount} items`

  return res;
}, args))({tag:, count, item})