Rule
[ class tree: Rule ] [ index: Rule ] [ all elements ]

Class: Formagic_Rule_Length

Source Location: /Rule/Length.php

Class Overview

Formagic_Rule
   |
   --Formagic_Rule_Length

Checks if value is between min and max length


Author(s):

  • Florian Sonnenburg
  • Marc Schrader

Version:

  • $Id: Length.php 17 2007-08-19 20:40:10Z meweasle $

Copyright:

  • Copyright (c) 2007 Marc Schrader

Variables

Methods


Inherited Variables

Inherited Methods

Class: Formagic_Rule

Formagic_Rule::__construct()
Constructor
Formagic_Rule::check()
Abstract of main check method. Returns boolean value of check success.
Formagic_Rule::getCode()
Returns error code of rule
Formagic_Rule::getLevel()
Returns error level of rule. Default is Formagic::ERROR
Formagic_Rule::getMessage()
Returns error message of rule
Formagic_Rule::getType()
Returns rule type identification string

Class Details

[line 59]
Checks if value is between min and max length

If only one numeric value is passed as argument, this value is interpreted as min length value.

Supported arguments are:

  • (integer)min: Minimum length of submitted value
  • (integer)max: Maximum length of submitted value
Usage examples:
  • addRule('mandatory')
// any length will do

  • addRule('mandatory', 'errorMessage', 10);
// at least 10 characters

  • addRule('mandatory', 'errorMessage', array('min' => 1));
// same as addRule('mandatory')

  • addRule('mandatory', 'errorMessage', array('max' => 10));
// 1 to 10 characters

  • addRule('mandatory', 'errorMessage', array('min' => 5, 'max' => 10));
// 5 to 10 characters




Tags:

author:  Florian Sonnenburg
author:  Marc Schrader
version:  $Id: Length.php 17 2007-08-19 20:40:10Z meweasle $
copyright:  Copyright (c) 2007 Marc Schrader


[ Top ]


Class Variables

$_errorCode =  1

[line 77]

Default error code



Tags:

access:  protected

Type:   integer
Overrides:   Array


[ Top ]



Class Methods


constructor __construct [line 92]

void __construct( string $type, [ $errorMessage = null], [array $args = null])

Extends parent constructor



Tags:

access:  public


Overrides Formagic_Rule::__construct() (Constructor)

Parameters:

string   $type  
array   $args  
   $errorMessage  

[ Top ]

method check [line 125]

boolean check( $item, Formagic_Item $itemObj)

Performs rule check

Length rule checks if value is between min and max length. (integer)_args['min']: Min length (integer)_args['max']: Max length




Tags:

access:  public


Overrides Formagic_Rule::check() (Abstract of main check method. Returns boolean value of check success.)

Parameters:

Formagic_Item   $itemObj  
   $item  

[ Top ]


Documentation generated on Thu, 23 Aug 2007 00:29:43 +0200 by phpDocumentor 1.4.0