Magik.Validator.validate

You're seeing just the function validate, go back to Magik.Validator module for more information.
Link to this function

validate(value, validators)

View Source

Specs

validate(any(), keyword()) :: :ok | error()

Validate value against list of validations.

iex(13)> Magik.Validator.validate("email@g.c", type: :string, format: ~r/.+@.+.[a-z]{2,10}/)
{:error, "format not matched"}

All supported validations:

  • type: validate datatype
  • format: check if binary value matched given regex
  • number: validate number value
  • length: validate length of supported types. See validate_length/2 for more details.
  • in: validate inclusion
  • not_in: validate exclusion
  • func: custom validation function follows spec func(any()):: :ok | {:error, message::String.t()}