When property validation on a nested class fails, i'd expect:
to have a "path" to the given property in the validation result
to have also an error message related to that final property
In my case if the home address street property is failing, i'd expect:
the "full" path to be homeAddress.street
and also i'd expect a street property related error message: e.g. street must contain a number or street name must not be empty and same for the city
Currently what i get:
no full path, just a plain propertyName: homeAddress
and just a homeAddress is invalid message - without the detail on which fields (2) were failed
NOTES:
i'd probably keep a "local" message / property details (like it is now) and also have a full property path with the last property/ies failing
if multiple home address properties were failing, i'd expect a failure message for each (or at least a switch so that the validator could work in this mode too) - e.g. fulfills - to use the current approach and validateNested to use mine...
Given the situation below using the validator gives me 2 failures, but unfortunately on the 2nd (nested) failure it just says: Home Address is invalid.
Although this statement is true, the detail that the home address Street property that's invalid get's missing.
Also i'd expect a path property that would contain the parent object's path property extended with then failed property to be present, like: homeAddress.location.lat property is missing. Given this property it would be possible to easily match the control on the UI and ensure that the error is displayed there
NOTE: If you remove the return statement from the pesronComponent's executeValidation fn, then there's a code which emulates such errors, everything rest is done by this "framework" of mine. The only thing I miss is a VALIDATION library that's able to provide the data in the format (with that path) - the only one I've found is not working in StackBlitz and it's not supported...
This ticket #12 also relates to fulfills vs suggested validateNested! My request (beside that described in #12) is also to have fully expanded property paths too.
When property validation on a nested class fails, i'd expect:
In my case if the home address street property is failing, i'd expect:
Currently what i get:
NOTES:
Given the situation below using the validator gives me 2 failures, but unfortunately on the 2nd (nested) failure it just says: Home Address is invalid.
Although this statement is true, the detail that the home address Street property that's invalid get's missing.
Also i'd expect a path property that would contain the parent object's path property extended with then failed property to be present, like: homeAddress.location.lat property is missing. Given this property it would be possible to easily match the control on the UI and ensure that the error is displayed there
NOTE: If you remove the return statement from the pesronComponent's executeValidation fn, then there's a code which emulates such errors, everything rest is done by this "framework" of mine. The only thing I miss is a VALIDATION library that's able to provide the data in the format (with that path) - the only one I've found is not working in StackBlitz and it's not supported...
Full sample: https://stackblitz.com/edit/ups-validation-sample?file=src%2Fapp%2Ftest-validation%2Fperson.module.ts,src%2Fapp%2Ftest-validation%2Fperson.component.ts,src%2Fapp%2Ftest-validation%2Fvalidator.ts
I have a model:
I have created a PersonValidator and an AddressValidator