Skip to content

Conversation

@jack828
Copy link

@jack828 jack828 commented Dec 17, 2020

If validators is an array, always run regardless of specified set (because using an array is a shorthand for { all: [...] })
If validators is an object, use the specified set validator, if it doesn't exist, fall back and use the all validator.

Use case:

      firstName: {
        type: String,
        validators: {
          all: [required]
        }
      },
      lastName: {
        type: String,
        validators: [required]
      },
      agency: {
        type: String,
        validators: {
          test: [required]
        }
      },

In schemata's current state, if you validate {} with the test set, it will only fail validation on agency field.

With these changes, it will correctly fail on all fields.

If you need to disable a validator field, you simply:

      agency: {
        type: String,
        validators: {
          all: [],
          test: [required]
        }
      },

Or just omit validators

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant