Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Exclusive attribute validation mode #272

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Exclusive attribute validation mode #272

wants to merge 2 commits into from

Conversation

flogiston
Copy link

Sometimes it makes sense to permit only those attributes which are explicitly declared within the ruleset. It makes validation stricter and prevents typos and unwanted values. This small feature helped us pinpoint bugs in our API output. It also works with custom validators (via global options) and nested attributes (to the extent validate.js supports them).

INPUT

{
    name: "Nicklas",
    age: 23
}

CONSTRAINTS

{
    name: true
}

RESULT

Output of validate(input, constraints, { exclusive: true }):

{
    age: ['Age is not permitted (exclusive mode)']
}

@coveralls
Copy link

coveralls commented Jun 19, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 7fc33dc on gabi-com:master into cccc345 on ansman:master.

validate.js Outdated Show resolved Hide resolved
validate.js Show resolved Hide resolved
@ansman ansman force-pushed the master branch 4 times, most recently from feffe94 to 40e06a1 Compare June 15, 2019 17:55
@joker-777
Copy link

@ansman Why can't this be merged? I think is an awesome feature!

@joker-777
Copy link

@ansman ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants