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
I find that changing the error message of a schematic is quite cumbersome. It would be nice to have an easy to set the error message in a schematic. In some cases, the default error message is too long or too generic.
For example, oneof/1 with two schema schematics provides an error with the full signature of both modules.
I tried doing %Schematic{oneof([schematic1(), schematic2()]) | message: fn -> ... end}, but that is ignored because the unify function references the default message function.
Another example is that I had to do the following to get the messages to be consistent with the included schematics.
defdecimaldoschematic=raw(fnintwhenis_integer(int)->true%Decimal{}->truestringwhenis_binary(string)->caseDecimal.parse(string)do{%Decimal{},""}->true_->falseend_->falseend,message: "expected a decimal")%{schematic|message: fn->"a decimal"end}end
all/1 is another that would benefit from being able to set a single error message regardless of which schematic fails.
The text was updated successfully, but these errors were encountered:
Hi. Enjoying the library so far.
I find that changing the error message of a schematic is quite cumbersome. It would be nice to have an easy to set the error message in a schematic. In some cases, the default error message is too long or too generic.
For example,
oneof/1
with twoschema
schematics provides an error with the full signature of both modules.I tried doing
%Schematic{oneof([schematic1(), schematic2()]) | message: fn -> ... end}
, but that is ignored because theunify
function references the default message function.Another example is that I had to do the following to get the messages to be consistent with the included schematics.
all/1
is another that would benefit from being able to set a single error message regardless of which schematic fails.The text was updated successfully, but these errors were encountered: