How do if
of the controller return TRUE
or FALSE
according to check()
of Validator?
Currently it returns Boolean for validate();
, but I wanted it to continue until the end of the code, to then return the Boolean.
<?php
# relatorio venda controller
class RelatorioVendaController {
public function __construct() {
$form['nome'] = 'Ricardo';
$form['idade'] = 24;
if(RelatorioVenda::validate($form)){
print 'Nenhum erro.';
}
}
}
# relatorio venda model
class RelatorioVendaModel extends RelatorioModel {
public static function validate($form){
$validators = array(
"nome" => "required",
"idade" => "required"
);
parent::rules($form, $validators);
}
}
# relatorio model
class RelatorioModel {
public static function rules($form, $validators){
// junta os arrays foreach e executa a validacao
Validator::check($field, $map['field'], $map['validator']);
}
}
class Validator {
public static function check($field, $value, $validator){
// execute validator(field, value)
if(no erros)
return true;
}
public function required($field, $value){
// validator
}
}
?>