Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Permissive Mode #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rkesters
Copy link

@rkesters rkesters commented Mar 24, 2021

The PR purpose is to add a Permissive Mode that creates a validator that will remove the any "extra" properties and validate the rest.

Permissive Mode

  • Is activated when --generatePermissive and --noExtraProps are both true. Permissive Mode only makes sense when the main validator is set to not allow extra props.
  • Will create a new validator called cleanAndValidate that will allow the user to pass an object that has extra props and will validate and return the object with the extras removed.
  • Note that cleanAndValidate is NOT pure
  • the validate validator is also created and works as before

Other Changes

  • Added peer dependency to ajv because the lack of any dep in the package.json was odd and confusing.
  • Added output CLI option, this was done to allow for better ergonomics in testing
  • Added unit tests.
  • Added exported type of AllowedTypeNames when --collection is used, a union of all the type names
  • Added exported type of AllowedTypes when --collection is used, a union of all the types
  • Added exported overload for validate and cleanAndValidate to accept type of AllowedTypeNames when --collection is used
    • Provides better type ergonomics

@rkesters rkesters marked this pull request as ready for review March 24, 2021 02:11
@rkesters rkesters changed the title Add Permissive Mode feat: Add Permissive Mode Mar 24, 2021
@rkesters rkesters force-pushed the rkesters/inexactValidator branch from 06194f2 to 8a7a657 Compare March 24, 2021 02:13
@rkesters
Copy link
Author

@ForbesLindesay can you take a look?

@rkesters rkesters force-pushed the rkesters/inexactValidator branch 2 times, most recently from 9fbd499 to 5d7687e Compare March 25, 2021 20:56
Added permissved mode and some type ergonomics
@rkesters rkesters force-pushed the rkesters/inexactValidator branch from 5d7687e to adab2f4 Compare March 25, 2021 21:00
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