-
-
Notifications
You must be signed in to change notification settings - Fork 886
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
strict: true
should enable all strict mode options (aka, be like typescript)
#1392
Comments
@G-Rath is the proposal to change It probably needs to be better defined then and I think it may be better to postpone till v8 release in a couple of months... Currently there is:
Possibly, with the change there would be:
Does it make sense? |
If a new major is coming out soon, then 💯 agree & am happy for it to wait until then since it'll give us more freedom.
Totally! I didn't realise Ultimately this boils down to "I want to have one property I can set to Then, thinking on how to go about that, it brings to mind the way TypeScript handle their So yes the list of properties you've written up makes sense and I think would be good. The only adjustment I'll make would be on those last two:
This might have been what you were meaning, but want to be clear :) Some examples
|
Ok, yes - that’s what I meant - strictSomething overrides strict atm strict: true indeed does not change anything - it’s just default. strictSchema and strictNumbers is just something that will be added to retain the current strict: true behaviour, no such options atm. another options would be to allow strict as object with properties schema/defaults/types/tuples (in addition to true/false/log values) - maybe it’s better. in this case you either set strict or individual settings but not both, so it’s easier and less confusing. |
What version of Ajv you are you using?
v7
What problem do you want to solve?
Whenever I enable strict mode I always pass
strict: true
, only to then remember that that doesn't do anything, as I've got to actually set two other properties totrue
.What do you think is the correct solution to problem?
When I do
strict: true
, use that as the default for all strict-mode options - that way all strict-mode options will be enabled when I passstrict: true
while allowing me to turn off the ones I don't want by explicitly setting them tofalse
orlog
.This is the behaviour I've come to expect from having worked with TypeScript for so long, as it's
strict
mode is pretty much the same as ajvs.Will you be able to implement it?
Yes :)
The text was updated successfully, but these errors were encountered: