isValid

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

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

Argument Reference

type string
Required

The valid format for the data.
Values:
  • any
  • array
  • binary
  • boolean
  • component
  • creditcard
  • date
  • email
  • eurodate
  • float
  • function
  • guid
  • integer
  • numeric
  • query
  • range
  • regex
  • regular_expression
  • social_security_number
  • ssn
  • string
  • struct
  • telephone
  • time
  • time
  • url
  • usdate
  • uuid
  • variablename
  • xml
  • zipcode

value any
Required

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.

Compatibility

ColdFusion:

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

Examples
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", "user@example.com")

Expected Result: true

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub