laravel 4应用程序有多种形式,
在下面的示例中,如果validate
的值为$register
$form
加载register
规则
class Validation {
private $register = array(
"nick" => "required|min:2",
"name" => "required|min:2",
"surname" => "required|min:2",
"day" => "required",
"month" => "required",
"year" => "required",
"country" => "required",
"address" => "required",
"city" => "required",
"postalCode" => "required",
"email" => "Required|Between:3,64|Email",
'password' =>'Required|AlphaNum|Between:6,32|Confirmed',
'password_confirmation'=>'Required|AlphaNum',
"currency" => "required",
"language" => "required"
);
private $support = array(
"text"=>"required",
"subject"=>"required"
);
public static function validate($input,$form) {
return Validator::make($input, $form);
}
答案 0 :(得分:0)
自己找到答案 - 使用变量变量
http://php.net/manual/es/language.variables.variable.php
public static function validate($input,$form) {
return Validator::make($input,self::$$form);
}