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:
anyarraybinarybooleancomponentcreditcarddateemaileurodatefloatfunctionguidintegernumericqueryrangeregexregular_expressionsocial_security_numberssnstringstructtelephonetimeurlusdateuuidvariablenamexmlzipcode
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
© 2012–present Foundeo, Inc. and the CFDocs contributors.
Licensed under the MIT License.
ColdFusion is a trademark of Adobe Systems Incorporated.
https://cfdocs.org/isvalid