Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CBooleanValidator
  • CCaptchaValidator
  • CCompareValidator
  • CDateValidator
  • CDefaultValueValidator
  • CEmailValidator
  • CExistValidator
  • CFileValidator
  • CFilterValidator
  • CInlineValidator
  • CNumberValidator
  • CRangeValidator
  • CRegularExpressionValidator
  • CRequiredValidator
  • CSafeValidator
  • CStringValidator
  • CTypeValidator
  • CUniqueValidator
  • CUnsafeValidator
  • CUrlValidator
  • CValidator
  • X2UrlValidator
  • Overview
  • Package
  • Class
  • Tree

Class CNumberValidator

CNumberValidator validates that the attribute value is a number.

In addition to the CValidator::$message property for setting a custom error message, CNumberValidator has a couple custom error messages you can set that correspond to different validation scenarios. To specify a custom message when the numeric value is too big, you may use the CNumberValidator::$tooBig property. Similarly with CNumberValidator::$tooSmall. The messages may contain additional placeholders that will be replaced with the actual content. In addition to the "{attribute}" placeholder, recognized by all validators (see CValidator), CNumberValidator allows for the following placeholders to be specified:
  • {min}: when using CNumberValidator::$tooSmall, replaced with the lower limit of the number CNumberValidator::$min.
  • {max}: when using CNumberValidator::$tooBig, replaced with the upper limit of the number CNumberValidator::$max.
CComponent
Extended by CValidator
Extended by CNumberValidator
Package: system\validators
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/validators/CNumberValidator.php
Methods summary
protected
# validateAttribute( CModel $object, string $attribute )

Validates the attribute of the object. If there is any error, the error message is added to the object.

Validates the attribute of the object. If there is any error, the error message is added to the object.

Parameters

$object
CModel
$object the object being validated
$attribute
string
$attribute the attribute being validated
public string
# clientValidateAttribute( CModel $object, string $attribute )

Returns the JavaScript needed for performing client-side validation.

Returns the JavaScript needed for performing client-side validation.

Parameters

$object
CModel
$object the data object being validated
$attribute
string
$attribute the name of the attribute to be validated.

Returns

string
the client-side validation script.

Since

1.1.7

See

CActiveForm::$enableClientValidation

Overrides

CValidator::clientValidateAttribute()
Methods inherited from CValidator
addError(), applyTo(), createValidator(), isEmpty(), validate()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Properties summary
public boolean $integerOnly false
#

whether the attribute value can only be an integer. Defaults to false.

whether the attribute value can only be an integer. Defaults to false.

public boolean $allowEmpty true
#

whether the attribute value can be null or empty. Defaults to true, meaning that if the attribute is empty, it is considered valid.

whether the attribute value can be null or empty. Defaults to true, meaning that if the attribute is empty, it is considered valid.

public integer|float $max
#

upper limit of the number. Defaults to null, meaning no upper limit.

upper limit of the number. Defaults to null, meaning no upper limit.

public integer|float $min
#

lower limit of the number. Defaults to null, meaning no lower limit.

lower limit of the number. Defaults to null, meaning no lower limit.

public string $tooBig
#

user-defined error message used when the value is too big.

user-defined error message used when the value is too big.

public string $tooSmall
#

user-defined error message used when the value is too small.

user-defined error message used when the value is too small.

public string $integerPattern '/^\s*[+-]?\d+\s*$/'
#

the regular expression for matching integers.

the regular expression for matching integers.

Since

1.1.7
public string $numberPattern '/^\s*[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?\s*$/'
#

the regular expression for matching numbers.

the regular expression for matching numbers.

Since

1.1.7
Properties inherited from CValidator
$attributes, $builtInValidators, $enableClientValidation, $except, $message, $on, $safe, $skipOnError
API documentation generated by ApiGen 2.8.0