Alpha and String - MajAhd/elx_validation Wiki

string

data = %{ 
     user_name1: "john_007",
     user_name2: 1879,   ---> return error 
}
rules = [
      %{
        field: "user_name1",
        validate: ["string"]
      },
     %{
        field: "user_name2",
        validate: ["string"]
      }
    ]

alpha

data = %{ 
     p1: "John Doe",
     p1: "James 007",   ---> return error 
   }

rules = [
      %{
        field: "p1",
        validate: ["alpha"]
      },
     %{
        field: "p2",
        validate: ["alpha"]
      }
    ]

start_with:foo

 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

 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"]
      }
]