Skip to content

Creators/modifiers that return null values fail with allowNull #89

@psvet

Description

@psvet
obey.modifier('returnNullIfInvalid', val => {
  return val && arrayOfValidValues.includes(val) ? val : null
})

const model = obey.model({
  name: { type: 'string', modifier: 'returnNullIfInvalid', allowNull: true }
})

model.validate({ name: 'some invalid string' }) // 'Value must be a string'

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions