Skip to content

Validate key without making it required? #119

Description

@marcysutton

I want to validate a schema to catch incorrect keys while keeping them optional. I've looked through the options, but I'm not sure if this is possible.

Here's a small portion of my schema for accessibility checks, I want to validate the key incomplete while keeping it optional:

messages: {
	required: true,
	type: 'object',
	properties: {
		fail: {
			required: true,
			type: 'string'
		},
		pass: {
			required: true,
			type: 'string'
		},
		incomplete: {
			type: ['string', 'object']
		}
	}
}

The only thing I've gotten revalidator to complain about is if I make incomplete required. The motivation for this change is I want to prevent check authors from using undefined: {} instead of incomplete: {}, where only some checks will have incomplete messages specified (hence the optional bit).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions