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 CStringValidator

CStringValidator validates that the attribute value is of certain length.

Note, this validator should only be used with string-typed attributes.

In addition to the CValidator::$message property for setting a custom error message, CStringValidator has a couple custom error messages you can set that correspond to different validation scenarios. For defining a custom message when the string is too short, you may use the CStringValidator::$tooShort property. Similarly with CStringValidator::$tooLong. The messages may contain placeholders that will be replaced with the actual content. In addition to the "{attribute}" placeholder, recognized by all validators (see CValidator), CStringValidator allows for the following placeholders to be specified:
  • {min}: when using CStringValidator::$tooShort, replaced with minimum length, CStringValidator::$min, if set.
  • {max}: when using CStringValidator::$tooLong, replaced with the maximum length, CStringValidator::$max, if set.
  • {length}: when using CValidator::$message, replaced with the exact required length, CStringValidator::$is, if set.
CComponent
Extended by CValidator
Extended by CStringValidator
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/CStringValidator.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 integer $max
#

maximum length. Defaults to null, meaning no maximum limit.

maximum length. Defaults to null, meaning no maximum limit.

public integer $min
#

minimum length. Defaults to null, meaning no minimum limit.

minimum length. Defaults to null, meaning no minimum limit.

public integer $is
#

exact length. Defaults to null, meaning no exact length limit.

exact length. Defaults to null, meaning no exact length limit.

public string $tooShort
#

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

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

public string $tooLong
#

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

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

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 string $encoding
#

the encoding of the string value to be validated (e.g. 'UTF-8'). This property is used only when mbstring PHP extension is enabled. The value of this property will be used as the 2nd parameter of the mb_strlen() function. If this property is not set, the application charset will be used. If this property is set false, then strlen() will be used even if mbstring is enabled.

the encoding of the string value to be validated (e.g. 'UTF-8'). This property is used only when mbstring PHP extension is enabled. The value of this property will be used as the 2nd parameter of the mb_strlen() function. If this property is not set, the application charset will be used. If this property is set false, then strlen() will be used even if mbstring is enabled.

Since

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