Skip to content

FieldValidation 的使用 #22

Closed
Closed
@Brook3

Description

@Brook3

希望在FieldValidation的使用中加入使用用例,方便查找与使用。
另外我还有一个问题,不知道是方法使用不当还是……,详情:
报错:

array(1) { [0]=> array(2) { ["name"]=> string(3) "age" ["msg"]=> string(52) "age must be an integer and value range {min} ~ {max}" } } 

运行代码:

        $data = [
            'id' => 1,
            'name' => '12345',
            'sex' => 0,
            'age' => 25,
            'love' => 'play'
        ];
        $v = v::check($data, [
            ['id', 'required'],
            ['name', 'required|string:5,10', 'msg' => '5~10位的字符串'],
            ['sex', 'required|enum:0,1'],
            ['age', 'requiredIf:sex,0|int']
        ]);
        if ($v->isFail()) {
            var_dump($v->getErrors());
        }

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions