Skip to content
Majid Ahmaditabar edited this page Dec 10, 2021 · 9 revisions

Welcome to the elx validation!

How To use

example_data = %{
    first_name: "Majid"
}
rules = [
     %{
        field: "first_name",   
        as: "first name", 
        validate: ["required", "string", "max:128"].
      },
 ]

  • field : The Field name that need to validate
  • as : its optional and use for response error
  • validate : list of rules and validations

ElxValidation.make(example_data , rules)

if it has error:

%{
  errors: [
     name: ["Error Message" , "Error Message"]
  ], 
  failed: true
}

Or if it hasnt error :

%{
   errors: [], 
   failed: false
}
Clone this wiki locally