25                 return $this->cfg->value;
    34                 $this->cfg->set(
'value', $value);
    44         public function addRule($type, $prm=null, $msg=null) {
    45                 if (!is_array($prm) && !is_callable($prm))
    47                 $this->cfg->setInArray(
'rules', $type, $prm);
    59                 return $this->cfg->checkInArray(
'rules', $type);
    68                 $this->cfg->delInArray(
'rules', $type);
    77                 return $this->cfg->rules;
    86                 $this->errors = array();
    88                 $noNeedRequired = $this->cfg->noNeedRequired;
    89                 $val = $this->cfg->validEltArray && is_array($this->cfg->value) ? $this->cfg->value : array($this->cfg->value);
    90                 foreach($this->cfg->rules as $rule=>$prm) {
    91                         if (!is_numeric($rule)) {
    93                                         if ((in_array($rule, $noNeedRequired)) || !empty($v))
    94                                                 $valid = $this->{
'is'.ucfirst($rule)}($v, $prm) && $valid;
   110                         $this->errors[] = sprintf($this->
getMessage(
'required'), $this->cfg->label);
   124                 if (!is_numeric($val)) {
   125                         $this->errors[] = sprintf($this->
getMessage(
'numeric'), $this->cfg->label);
   138         public function isInt($val, $prm=null) {
   139                 if (!is_numeric($val) || $val != (
int)$val) {
   140                         $this->errors[] = sprintf($this->
getMessage(
'int'), $this->cfg->label);
   154                 if ($val == $prm[0]) {
   155                         $this->errors[] = sprintf($this->
getMessage(
'different'), $this->cfg->label, $prm[0]);
   168         public function isIn($val, $prm=null) {
   170                 $val = is_array($val)? $val : array($val);
   171                 $val = array_filter($val);
   173                         foreach($val as $v) {
   174                                 if (!in_array($v, $prm)) {
   175                                         $this->errors[] = sprintf($this->
getMessage(
'in'), $v, $this->cfg->label);
   192                         if ($val != $prm[0]->getRawValue()) {
   193                                 $this->errors[] = sprintf($this->
getMessage(
'equalInput'), $this->cfg->label, $prm[0]->label);
   197                         if ($val != $prm[0]) {
   198                                 $this->errors[] = sprintf($this->
getMessage(
'equal'), $v, $this->cfg->label);
   216                 foreach($prm[
'fields'] as 
$f) {
   217                         $val = $prm[
'form']->getValue($f);
   221                 $ret = $nbFilled == 0 || $nbFilled == count($prm[
'fields']);
   224                         $this->errors[] = sprintf($this->
getMessage(
'groupedFields'), $this->cfg->label);
   241                 foreach($prm[
'fields'] as 
$f) {
   242                         $val = $prm[
'form']->getValue($f);
   246                 if ($nbFilled == 0) {
   248                         $this->errors[] = sprintf($this->
getMessage(
'atLeastOneField'), $this->cfg->label);
   262                 $tmp = call_user_func($prm, $val);
   263                 if ($tmp !== 
true && !is_null($tmp)) {
   264                         $tmp = is_string($tmp) ? $tmp : 
'callback';
   266                         $this->errors[] = sprintf($msg ? $msg : $tmp, $this->cfg->label);
   279         public function isUrl($val, $prm=null) {
   280                 if (!filter_var($val, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED)) {
   281                         $this->errors[] = sprintf($this->
getMessage(
'url'), $this->cfg->label);
   295                 if (!filter_var($val, FILTER_VALIDATE_EMAIL)) {
   296                         $this->errors[] = sprintf($this->
getMessage(
'email'), $this->cfg->label);
   313                 if (array_key_exists(
'value', $prm) && $val == $prm[
'value'])
   316                 $table = $prm[
'table'] instanceof 
db_table? $prm[
'table'] : 
db::get(
'table', $prm[
'table']);
   317                 $nb = $table->count(array(
   318                         'where'=>array($prm[
'field']=>$val),
   322                         $this->errors[] = sprintf($this->
getMessage(
'dbUnique'), $val, $this->cfg->label);
   338                 $table = $prm[
'table'] instanceof 
db_table? $prm[
'table'] : 
db::get(
'table', $prm[
'table']);
   339                 $nb = $table->count(array(
   340                         'where'=>array($prm[
'field']=>$val),
   344                         $this->errors[] = sprintf($this->
getMessage(
'dbExists'), $val, $this->cfg->label);
   367                 $this->cfg->setInArray(
'messages', $name, $msg);
 static htmlOut($val, $key=false)
 
isDbExists($val, array $prm)
 
isNumeric($val, $prm=null)
 
isRequired($val, $prm=null)
 
isDifferent($val, $prm=null)
 
addRule($type, $prm=null, $msg=null)
 
isAtLeastOneField($val, $prm=null)
 
static get($type, $table, array $prm=array())
 
isCallback($val, $prm=null)
 
isGroupedFields($val, $prm=null)
 
isDbUnique($val, array $prm)