You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to use a class in a type definition. But since it is not a blackbox, it will be validate. While an instance has all the properties it should have, they are not described in a schema and hence produce errors. But describing whole schema for every used class is not a good practice. It leads at least to duplication of code but also violates encapsulation. I'd expect some class-level approach.
It would be nice if classes could expose function that would be used for validation. Also utility.isObjectWeShouldTraverse should return false if the schema type is custom class, validation should only check whether the value is of type of the class. The value should be then validated only by custom provided function. Also it should not be necessary to state that is is blackbox if custom validation function is provided.
The class defined validation function could be static and instance methods. So e.g.
staticvalidate(){}validate(){}
Anyways: currently it is not clear from documentation how should be custom class type definition treated.
The text was updated successfully, but these errors were encountered:
If this is a bug report, please be sure to include, at minimum, example code showing a small schema and any necessary calls with all their arguments, which will reproduce the issue. Even better, you can link to a saved online code editor example, where anyone can immediately run the code and see the issue.
If you are requesting a feature, include a code example of how you imagine it working if it were implemented.
If you need to edit your issue description, click the [...] and choose Edit.
Be patient. This is a free and freely licensed package that I maintain in my spare time. You may get a response in a day, but it could also take a month. If you benefit from this package and would like to see more of my time devoted to it, you can help by sponsoring.
The approach has been to validate class instances as well as possible, but there hasn't been a lot of thought put into customizing that validation. My thinking is that people may want to validate instances of classes they don't own, so it would be best to support this in the schema definition. It might look something like this:
It is possible to use a class in a type definition. But since it is not a blackbox, it will be validate. While an instance has all the properties it should have, they are not described in a schema and hence produce errors. But describing whole schema for every used class is not a good practice. It leads at least to duplication of code but also violates encapsulation. I'd expect some class-level approach.
It would be nice if classes could expose function that would be used for validation. Also
utility.isObjectWeShouldTraverse
should return false if the schema type is custom class, validation should only check whether the value is of type of the class. The value should be then validated only by custom provided function. Also it should not be necessary to state that is is blackbox if custom validation function is provided.The class defined validation function could be static and instance methods. So e.g.
Anyways: currently it is not clear from documentation how should be custom class type definition treated.
The text was updated successfully, but these errors were encountered: