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
Because there are no errors in InvalidData exception I've tried the error printer (with TypeToStringConverter) but it does some prefixing which breaks the passed message. That's probably not a bug but a feature of the TypeToStringConverter.
throw ValueDoesNotMatch::createFromString("message:invalidJson", ...) will be converted via ErrorPrinter to "settings: message:invalidJson" in this case.
Expected Behavior
Should contain that invalid field error?
Addition information
No response
The text was updated successfully, but these errors were encountered:
I am not sure what to do here (except better documenting the types and callbacks and documenting the printers)
Each exception thrown for a field is mapped to the field. All the fields in "fields" key are in fact invalid fields.
This is not the case when the error is thrown from the before/after mapped object callbacks. In this and only this case the error is added to the object and printed in errors instead of fields.
If you want to add an error to the object, either throw in the after class callback or use method addError() of the type accessible in context of after class callback.
Mixing errors from object and its fields is a no-go, but some improvements may be done:
rename fields to fieldErrors and errors to typeErrors? (same logic is used also for ArrayShape, that is currently not used by mapper itself, but may be used in custom rules and callbacks)
add a way to access object type from field callback (I'd really prefer to not do that)
I'll write completely new printers in future, because current one are not so easy to read and also do not count with printing invalid values, large hierarchies and the planned extended data types support, but it is crazy complex...
Btw, your example misses the null value in callback, this would fail the validation completely.
Steps to reproduce should also contain call to the processor, with an input causing the error.
Library version
0.1.0, 0.2.0
Description
When using
throw ValueDoesNotMatch
, resultingInvalidData
exception contains emptyerrors
.Steps to reproduce
Input class
Error formating
Actual Behavior
There are no errors but there are some invalid fields.
Because there are no
errors
inInvalidData
exception I've tried the error printer (withTypeToStringConverter
) but it does some prefixing which breaks the passed message. That's probably not a bug but a feature of theTypeToStringConverter
.throw ValueDoesNotMatch::createFromString("message:invalidJson", ...)
will be converted viaErrorPrinter
to"settings: message:invalidJson"
in this case.Expected Behavior
Should contain that invalid field error?
Addition information
No response
The text was updated successfully, but these errors were encountered: