Funx.Validator.Positive (funx v0.8.2)

View Source

Validates that a number is strictly positive (> 0).

Optional Options

  • :message - Custom error message callback (value -> String.t())

Examples

iex> Funx.Validator.Positive.validate(5)
%Funx.Monad.Either.Right{right: 5}

iex> Funx.Validator.Positive.validate(0)
%Funx.Monad.Either.Left{left: %Funx.Errors.ValidationError{errors: ["must be positive"]}}

iex> Funx.Validator.Positive.validate(-5)
%Funx.Monad.Either.Left{left: %Funx.Errors.ValidationError{errors: ["must be positive"]}}

Summary

Functions

validate(value)

validate(value, opts)