Skip to content

Can't extend built-in validation for array #136

@mrspartak

Description

@mrspartak

So the example is here https://repl.it/repls/TemporalUnfoldedProcessor

const schema = {
  distribution: {
    type: 'array',
    min: 1,
    custom(val, errors) {
      //I don't get this message below
      console.log('distribution', val)
      return val
    },
    items: {
      type: 'number', convert: true,
      positive: true
    }
  },
};

The custom key is not working. Also, I don't use your library directly, I use moleculer framework and get this error when I put 'custom' key on arrays. On everything else works just fine.

Error [TypeError]: Cannot read property 'call' of undefined
at Array.eval (eval at compileRule (\node_modules\fastest-validator\lib\validator.js:
234:16), <anonymous>:136:36)
at Validator.eval (eval at compile (\node_modules\fastest-validator\lib\validator.js:
176:19), <anonymous>:10:14)
at \node_modules\fastest-validator\lib\validator.js:192:19
at validateContextParams (\moleculer\src\validator.js:48:17)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions