IsValid()
Tests whether a value meets a validation or data type rule.
IsValid( type=string, value=any, min_or_pattern=any, max=any );
Returns: Boolean
| Argument | Description |
|---|---|
|
type
string,
required
|
edit
The valid format for the data; one of the following:
|
|
value
any,
required
|
edit
The value to test. |
|
min_or_pattern
any,
optional
|
edit
The minimum valid value; used only for range validation or a JavaScript regular expression that the parameter must match; used only for regex or regular_expression validation. Alias: min, pattern |
|
max
any,
optional
|
edit
The maximum valid value; used only for range validation. |
Examples
edit<cfset anArray = []>
<cfset boolean = true>
<cfset email = "test@test.com">
<cfset guid = createGUID()>
<cfset integer = 15>
<cfset string = "Hello World">
<cfset http_url = "http://www.test.com">
<cfset uuid = createUUID()>
<cfoutput>
Array: #isValid('array', anArray)#<br>
Boolean: #isValid('boolean', boolean)#<br>
Email: #isValid('email', email)#<br>
GUID: #isValid("guid", guid)#<br>
Integer: #isValid("integer", integer)#<br>
String: #isValid("string", string)#<br>
URL: #isValid("url", http_url )#<br>
UUID: #isValid("uuid", uuid)#
</cfoutput>
See also
- Arrays
- Binary data
- Booleans
- Components (CFCs)
- Date and time
- Decision logic
- Queries
- Regex
- Strings
- Structures
- CreateGUID()
- CreateUUID()
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)