Validation reference

HasFileSize

class HasFileSize

Checks that a file’s size is less than or equal to the bytes specified in $allowedSize.

validate($value, $allowedSize)
Parameters:$allowedSize (int) – Allowed file size in bytes.

HasLinkCount

class HasLinkCount

Checks that the quantity of hyperlinks in a string is less than the amount specified in $allowedLinks.

validate($value[, $allowedLinks])
Parameters:$allowedLinks (int) – Allowed number of links. Defaults to 10.

HasWordCount

class HasWordCount

Checks that the word count in a string obeys the boundaries specified in $min and $max.

validate($value, $min[, $max])
Parameters:
  • $min (int) – Minimum number of words required.
  • $max (int) – Maximum number of words allowed.

IsAlphaNumeric

class IsAlphaNumeric

Checks that a string contains only alphanumeric characters.

IsBetween

class IsBetween

Checks that a value is between $min and $max. If the value is a string, the validator uses the length of the string to compute the validation.

validate($value, $min, $max)
Parameters:
  • $min (int) – Minimum value.
  • $max (int) – Maximum value.

IsCheckbox

class IsCheckbox

Checks that a value is either true or false.

IsDate

class IsDate

Checks that a string is a valid date representation.

Accepts numeric date values, such as 2010-08-18, 18/08/2010, or 08182010.

IsDateDay

class IsDateDay

Checks that a string is a valid date-day representation.

IsDateMonth

class IsDateMonth

Checks that a string is a valid date-month representation.

Accepts both numeric and string values, i.e. both 12 and December.

IsDateYear

class IsDateYear

Checks that a string is a valid date-year representation.

IsEmail

class IsEmail

Checks that a string is a valid email address. See RFC 2822.

IsIP

class IsIP

Checks that a string is a valid IP address, only IPv4.

IsMIMEType

class IsMIMEType

Checks that a file is one of the MIME types specified in $mimeTypes.

validate($value, $mimeTypes)
Parameters:$mimeTypes (arr) – Allowed MIME types.

IsMoney

class IsMoney

Checks that a string is a valid currency format.

Accepts US dollars, British pounds sterling, and euros.

IsNumeric

class IsNumeric

Checks that a value is numeric.

IsOneOf

class IsOneOf

Checks that a value is in a particular set of possible values.

validate($value, $option1, $option2...)
Parameters:$option.. (str) – Allowed options.

IsPhoneNumber

class IsPhoneNumber

Checks that a string is a valid US phone number.

IsPostalCode

class IsPostalCode

Checks that a string is a valid US or Canadian postal code.

IsRanked

class IsRanked

Checks that a series of values is uniquely ranked from 1 to the integer specified in $min.

validate($value, $min)
Parameters:$min (int) – Minimum number of required rank values.

IsRequired

class IsRequired

Checks that a value is not empty.

IsStateOrProvince

class IsStateOrProvince

Checks that a string is a valid US state or Canadian province.

Accepts abbreviations and full names, i.e. MN and Minnesota.

IsTime

class IsTime

Checks that a string is a valid time representation.

Accepts a wide range of values, such as:

  • 5:00
  • 5:00 A.M.
  • 3pm
  • 19:29

IsUnique

class IsUnique

Checks that the individual values in a series are all unique.

IsURL

class IsURL

Checks that a string is a valid URL. Uses filter_var() and FILTER_VALIDATE_URL.

IsWithinDateRange

class IsWithinDateRange

Checks that a value is within the date range specified in $minDate and $maxDate.

validate($value, $minDate, $maxDate)
Parameters:
  • $minDate (string) – Minimum date. Run through strtotime().
  • $maxDate (string) –

    Maximum date. Run through strtotime().

MatchesPattern

class MatchesPattern

Checks that a string matches the regular expression specified in $pattern.

validate($value, $pattern)
Parameters:$pattern (string) – Regular-expression pattern to which to match