Funx.Validator.Required (funx v0.8.0)
View SourceValidates that a value is present (not nil, not empty string, not Nothing).
Special Semantics
Required is the ONLY validator that runs on Maybe.Nothing.
All other validators skip Nothing values (from Prism projections).
This makes fields optional-by-default with explicit presence checks.
Failure Conditions
nil""(empty string)%Maybe.Nothing{}(from Prism projections)
Success Conditions
All other values, including:
0,false,[](falsy but present values)
Options
:message- Custom error message callback(value -> String.t())
Examples
iex> Funx.Validator.Required.validate("hello")
%Funx.Monad.Either.Right{right: "hello"}
iex> Funx.Validator.Required.validate(nil)
%Funx.Monad.Either.Left{left: %Funx.Errors.ValidationError{errors: ["is required"]}}
iex> Funx.Validator.Required.validate(0)
%Funx.Monad.Either.Right{right: 0}