joken
joken copied to clipboard
[DISCUSSION] Per-claim optional processing
Joken configuration now has a Joken.Claim
struct which has a :options
field. This came from the #182 PR. We could add custom messages, skipping the claim if some condition match and whatnot.
Ideas are welcome here.
There is two ways we can implement optional claims:
-
pass
nil
or:not_defined
atom into the validation function if claim is not defined at all. In this case the validation function will decide on the outcome. -
add an
optional: [claim1, claim2...]
parameter into the:options
in case we do not want to fail if some claim is not defined at all, if this claim is defined it will be still validated
On Joken 2 each claim might have its own options since now we use a "key" => %Joken.Claim{}
config map. I think it is easier to add flags there. What do you say?