-
Notifications
You must be signed in to change notification settings - Fork 13
✨ Adding validations #2285
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
✨ Adding validations #2285
Conversation
@bcb37, validations are working. Can you check it once? |
backend/packages/Upgrade/src/api/controllers/ExperimentController.ts
Outdated
Show resolved
Hide resolved
Adding validation of policy params
386d2c2
to
ca11dc1
Compare
export class MoocletTSConfigurablePolicyParametersDTO extends MoocletPolicyParametersDTO { | ||
@IsDefined() | ||
@ValidateNested() | ||
@Type(() => Prior) | ||
prior: Prior = new Prior(); | ||
prior: Prior; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation isn't quite working for me on the frontend when I fill in prior manually either, it allows me to hit "next" with an object like below. It does catch it on submit and give correct message, however the other validations will raise an error immediately as the user types.
{
"prior": {
"success": "d",
"failure": 2
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not add the default values in the class constructor because class transform uses this class constructor to create the definition and assign the object (to be tested) to the constructed object. If we are adding the default values, the constructor definition also contains the value which we don't want.
For testing, add the default value for Prior
in the types
Remove the "prior": { "success": 1, "failure": 1}
.
It will not throw an error.
I can add the appropriate config for the frontend side for validation to work correctly.
In addition to Dan's comment about the default values (which works if we're defining the types within the root), we also need to disallow extraneous attributes. That works if you add You'll notice that default values are used based on DTO for non-nested attributes (e.g. "batch_size"). I'm still fairly sure the nested types are not being added to the right |
@bcb37 I don't think that we have two different instances of |
To be continued, validation still need attention but closing as we need the default behavior. |
Adding validation of policy parameters