ElxValidation.Alpha (elx_validation v0.1.0)

string

  • The field under validation must be a string. If you would like to allow the field to also be null, you should assign the nullable rule to the field.
    data = %{
     user_name1: "john_007",
     user_name2: 1879,   ---> return error
    }
    rules = [
      %{
        field: "user_name1",
        validate: ["string"]
      },
     %{
        field: "user_name2",
        validate: ["string"]
      }
    ]

alpha

  • The field under validation must be entirely alphabetic characters.
    data = %{
     p1: "John Doe",
     p1: "James 007",   ---> return error
    }
    rules = [
      %{
        field: "p1",
        validate: ["alpha"]
      },
     %{
        field: "p2",
        validate: ["alpha"]
      }
    ]

start_with:foo

  • The field under validation must start with the given values.
data = %{
    start_code: "G123other_string",
    start_code2: "other_string". ---> return error
  }
rules = [
    %{
      field: "start_code",
      validate: ["start_with:G123"]
    },
    %{
      field: "start_code2",
      validate: ["start_with:Me32"]
    }
]

end_with:foo

  • The field under validation must end with the given values
    data = %{
      end_code: "other_stringG123",
      end_code2: "other_string". ---> return error
    }
    rules = [
      %{
        field: "end_code",
        validate: ["end_with:G123"]
      },
      %{
        field: "end_code2",
        validate: ["end_with:Me32"]
      }
    ]

Link to this section Summary

Functions

Validate String end value : target : "1234code" check:code -> passed

Validate Only Alpha data [a to z / A to Z]

Validate String data

Validate String starter value : target : "code1234" check:code -> passed

Link to this section Functions

Link to this function

end_with(target, end_value)

Validate String end value : target : "1234code" check:code -> passed

Link to this function

is_alpha(target)

Validate Only Alpha data [a to z / A to Z]

Link to this function

is_string(target)

Validate String data

Link to this function

start_with(target, start_value)

Validate String starter value : target : "code1234" check:code -> passed