Spec-Zone.ru › ColdFusion

isValid

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

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

  • CF7+
  • Lucee
  • BL 1.0.0+
  • See Also: isarray issimplevalue isnumeric isboolean isdate cfparam

    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
    • 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

    Check to see if a 235 is an integer

    Use the isValid function with integer as the type.

    isValid("integer", 235)

    Expected Result: true

    Validate an Email Address

    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

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API