-
Notifications
You must be signed in to change notification settings - Fork 119
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
setting $$strict=true for params should work with nested objects #314
Comments
Does it work if you add |
@ColinFrick Yes! I'll have to check and see if I should be using "strict:true" everywhere now instead of "$$strict:true". |
@ekellstrand top level is $$strict. Otherwise you wouldn’t be able to add a parameter with the name strict. |
OK, so that gets me going.
|
$$strict is only evaluated for the root schema. As far as I can tell it is the same behavior as if you have nested objects, children don't inherit the strict property from their parent either. If you always want I only can tell you what's in the documentation, maybe @icebob can tell you more. |
@ColinFrick Thank you for pointing me at the docs. The default values are new since I set this all up a few years back. I think docs are good and I'm going to close this out as "RTFM Success". Related question: It looks like the default options handles any nested objects. Do you know if there is any config setting to handle the top level |
Hi, @ColinFrick's explanation is right, no inheritance in properties, every property is evaluated on the given level and not affect the nested levels. If you would like to add // moleculer.config.js
module.exports = {
validator: {
type: "Fastest",
options: {
useNewCustomCheckerFunction: true,
defaults: {
object: {
strict: true
}
}
}
}
}; |
Thanks! Closing this as RTFM. |
Consider the following action definition. Take note of:
Now call this service with the following payload
$$strict seems work great for top level params. (ie, If I added "I_DONT_REMEMBER_HOW_TO_SPELL_ALIAS" at the top level, right under "alias" in my payload, validation correctly rejects it). It's only when I define an object that I see this problem.
ps. Thx for your efforts. I really enjoy working with Moleculer!
Edit: Sorry, Let me give you the software version details..
I tested with Chrome 104.0.5112.102 & Postman 9.28.2
The text was updated successfully, but these errors were encountered: