IsValid

Validates the incoming value against the giventype.

If the type is a range, the value is validated against the range. If the type is a pattern, the value is validated against the pattern. If the type is a date, the value is validated against the date format. If the type is a locale date, the value is validated against the locale date format. If the type is a regular expression, the value is validated against the regular expression.

Note we expressly do not support the `eurodate` type, since date formats vary across EU countries. For this, prefer the `LSIsDate( date, locale )` method instead.

Valid Types

  • array

  • binary

  • boolean

  • component

  • creditcard

  • date

  • email

  • float

  • function

  • guid

  • hex

  • integer

  • numeric

  • query

  • range

  • regex

  • regular_expression

  • social_security_number

  • ssn

  • string

  • struct

  • telephone

  • time

  • time

  • url

  • usdate

  • uuid

  • variablename

  • xml

  • zipcode

Method Signature

IsValid(type=[string], value=[any], min=[any], max=[any], pattern=[any])

Arguments

Argument
Type
Required
Description
Default

type

string

true

The type to validate the value against

value

any

true

Value to test for validaty on a given type

min

any

false

The minimum value for the range type or a pattern to validate the value against

max

any

false

The maximum value for the range type

pattern

any

false

The pattern to validate the value against

Examples

Check to see if a 235 is an integer

Use the isValid function with integer as the type.

Run Example

isValid( "integer", 235 );

Result: true

Validate an Email Address

Use the isValid function with email as the type.

Run Example

isValid( "email", "[email protected]" );

Result: true

Additional Examples

<bx:set anArray = [] >
<bx:set boolean = true >
<bx:set email = "[email protected]" >
<bx:set guid = createGUID() >
<bx:set integer = 15 >
<bx:set string = "Hello World" >
<bx:set http_url = "http://www.test.com" >
<bx:set uuid = createUUID() >

<bx:output>
	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 )#
</bx:output>

Last updated

Was this helpful?