ElxValidation.Numbers (elx_validation v0.1.3)

numeric

  • The field under validation must be numeric.
data = %{
     number1: 2121,
     number2: "2121"  ----> return error
  }
rules = [
   %{
      field: "number1",
      validate: ["numeric"]
    },
    %{
      field: "number2",
      validate: ["numeric"]
    }
]

digits:value

  • The field under validation must be numeric and must have an exact length of value.
data = %{
    age1: 12,
    age2: 9  ---> return error min 2 digit required
}
rules = [
    %{
      field: "age1",
      validate: ["digits:2"]
    },
   %{
      field: "age2",
      validate: ["digits:2"]
    }
]

Link to this section Summary

Functions

target must be a number : integer target 12345 -> its 5 digit value 5 -> passed if value 6 -> failed ** value is string because it comes from validation object

target must be a number : integer , float

Link to this section Functions

Link to this function

digits(target, value)

target must be a number : integer target 12345 -> its 5 digit value 5 -> passed if value 6 -> failed ** value is string because it comes from validation object

Link to this function

validation_numeric(target)

target must be a number : integer , float