chapter31

development in a land far far away…

at the moment

History is not what happened. History is what was written down.

New to ColdFusion MX7 the isValid() function tests whether a value meets a validation or data type rule and returns True if the value conforms to the rule; False, otherwise.

Function syntax

isValid(type, value)
isValid("range", value, min, max)
isValid("regex" or "regular_expression", value, pattern)

Example:


   Valid integer!

   Invalid Integer!



   Value is between 1 and 100

   Value is not between 1 and 100



   Word starts with a capital letter

   Word does not match pattern.

There are a lot of pre-existing functions that can already do a lot of what isValid() offers like:

  • isNumeric()
  • isBoolean()
  • isArray()
  • isQuery()
  • isStruct

But with isValid() you can do those as well as things like:

  • creditcard (mod10 checks for credit cards)
  • email
  • eurodate
  • guid
  • range
  • regex
  • url
  • usdate
  • variablename (a string formatted according to ColdFusion variable naming conventions)

There are also a few US specific test conditions as well like “ssn” and “telephone” etc.

All in all this is an extremely versatile tag to use for validation and will save you oodles of time!


Related Pages

Leave a Reply