Tests whether a value meets a validation or data type rule.

isValid(type, value, min, max, pattern) → returns boolean

Argument Reference

type string

The valid format for the data.
  • Any
  • Array
  • Binary
  • boolean
  • creditcard
  • component
  • date
  • time
  • email
  • eurodate
  • float
  • guid
  • integer
  • Numeric
  • Query
  • range
  • Regex
  • regular_expression
  • ssn
  • social_security_number
  • String
  • Struct
  • telephone
  • time
  • URL
  • UUID
  • usdate
  • variablename
  • xml
  • zipcode

value any

The value to test.

min numeric

The minimum valid value; used only for range validation.

max numeric

The maximum valid value; used only for range validation.

pattern string

A regular expression that the parameter must match;
used only for regex or regular_expression validation.



Version 7+ CF8+ - added component as a type option. CF11+ - no longer allows currency symbols at the start and commas inside a number. Can be reverted to legacy mode by setting this.strictNumberValidation = false in Application.cfc

Sample code invoking the isValid function

Use the isValid function with integer as the type.

isValid("integer", 235)

Expected Result: true

Use the isValid function with email as the type.

isValid("email", "")

Expected Result: true

Fork me on GitHub