Wiki

Clone wiki

validation-library / Validation Rules List

Following are the validation rules available in the library:

required

  • Parameter: no
  • Description: Returns false if the input field value is empty.

Example:

#!php

'name' => 'required'

email

  • Parameter: no
  • Description: Returns false if the input field value is not valid E-mail.

Example:

#!php

'email' => 'required|email'

alpha

  • Parameter: no
  • Description: Returns false if the input field value contains anything other than alphabetical characters.

Example:

#!php

'name' => 'required|alpha'

alpha_numeric

  • Parameter: no
  • Description: Returns false if the input field value contains anything other than alphabetical and numeric characters.

alpha_dash

  • Parameter: no
  • Description: Returns false if the input field value contains anything other than alpha-numeric characters, underscores or dashes.

numeric

  • Parameter: no
  • Description: Returns false if the input field value contains anything other than numeric characters.

lowercase

  • Parameter: no
  • Description: Returns false if the input field value contains anything other than lowercase letters.

uppercase

  • Parameter: no
  • Description: Returns false if the input field value contains anything other than uppercase letters.

strong_password

  • Parameter: no
  • Description: Returns false if password is not strong enough. Password should be 8 to 16 character string in length with at least one upper case letter, one lower case letter and one digit.
#!php

'password' => 'required|strong_password'

matches

  • Parameter: yes (input field you want to match value with separated with colon. Accepts only single parameter)
  • Description: Returns false if the input field does not match the one in the parameter.

In real world, it will be useful when you want to match your password field with password confirmation field

Example:

#!php

'password' => 'required|strong_password',
'password_confirmation' => 'required|strong_password|matches:password'

min_length

  • Parameter: yes (input field you want to match value with separated with colon. Accepts only single parameter)
  • Description: Returns false if the input field value is shorter than the parameter value.

Example:

#!php

'name' => 'required|min_length:10'

max_length

  • Parameter: yes (input field you want to match value with separated with colon. Accepts only single parameter)
  • Description: Returns false if the input field value is longer than the parameter value.

Example:

#!php

'name' => 'required|max_length:10'

exact_length

  • Parameter: yes (input field you want to match value with separated with colon. Accepts only single parameter)
  • Description: Returns false if the input field value is not exactly the parameter value.

Example:

#!php

'name' => 'required|exact_length:10'

Updated