Authored by ziy

添加,$this->validate和文档

... ... @@ -4,7 +4,7 @@ namespace Hood;
use Yaf\Controller_Abstract;
use Hood\Helper\View as hoodView;
use Yaf;
use Hood\Validator as hoodValidator;
class Action extends Controller_Abstract
{
private $_viewLink = array();
... ... @@ -168,6 +168,6 @@ class Action extends Controller_Abstract
*/
public function validate(array $data, array $rules, array $messagesAttribute = array())
{
return Validator::make($data, $rules, $messagesAttribute);
return hoodValidator::make($data, $rules, $messagesAttribute);
}
}
\ No newline at end of file
... ...
#Validator
```php
$validator = Validator::make(
['url_str' => 'http://www.baidu.com'],
['url_str' => 'url']
);
判断错误
$validator->fails();
判断正确
$validator->passes();
获取所有验证的第一个错误,可以指定验证字段的第一个错误
$validator->messages()->first([$key=null]);
获取所有验证的错误
$validator->messages()->all();
获取指定验证字段的所有错误
$validator->messages()->get($key);
判断是否有错误信息,可以指定验证字段
$validator->messages()->has([$key]);
设定自定义错误信息
$validator->messages()->customMessages(['key'=>'mes']);
设定指定验证字段错误消息
$validator->messages()->add($key,$mes);
```
##active_url
```php
Validator::make(
... ...