Skip to content

Commit fff2e19

Browse files
author
xiajianjun
committed
bug fix.some update
1 parent e57b98a commit fff2e19

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

document.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ run: `composer update`
6969
];
7070
}
7171
72-
// custom validator message
72+
// custom validator message, more {@see ValidatorTrait::defaultMessages()}
7373
public function messages()
7474
{
7575
return [
@@ -81,7 +81,7 @@ run: `composer update`
8181
//
8282
// use, at other class
8383
84-
$valid = Validator::make($_POST,)->validate();
84+
$valid = PageRequest::make($_POST,)->validate();
8585
if ( $valid->fail() ) {
8686
return $valid->getErrors();
8787
}
@@ -186,7 +186,7 @@ validator | description | rule example
186186
`required` | validate required | `['tagId,userId', 'required' ]`
187187
`length` | validate length | ....
188188
`size` | validate size | `['tagId', 'size', 'min'=>4, 'max'=>567]`
189-
`min` | validate min | `['title', 'min', 'min' => 40],`
189+
`min` | validate min | `['title', 'min', 'value' => 40],`
190190
`max` | validate max | ....
191191
`in` | validate in | ....
192192
`string` | validate string | ....

src/ValidatorTrait.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ public function firstError()
315315
{
316316
$e = $this->_errors;
317317

318-
return array_shift($e);
318+
return array_values(array_shift($e))[0];
319319
}
320320

321321
/**
@@ -328,7 +328,7 @@ public function lastError()
328328
{
329329
$e = $this->_errors;
330330

331-
return array_pop($e);
331+
return array_values(array_pop($e))[0];
332332
}
333333

334334
/**
@@ -349,9 +349,9 @@ public function defaultMessages()
349349
'required' => '{attr} is not block!',
350350
'length' => '{attr} length must at rang {min} ~ {max}',
351351
'size' => '{attr} must be an integer and at rang {min} ~ {max}',
352-
'min' => '{attr} minimum boundary is {min}',
353-
'max' => '{attr} maximum boundary is {max}',
354-
'in' => '{attr} must in {range}',
352+
'min' => '{attr} minimum boundary is {value}',
353+
'max' => '{attr} maximum boundary is {value}',
354+
'in' => '{attr} must in ({value})',
355355
'string' => '{attr} must be a string',
356356
'isArray' => '{attr} must be an array',
357357
'callback' => 'The custom callback validation fails of the [{attr}]!',
@@ -386,7 +386,7 @@ public function getMessage($name, array $params, $rule = [], $msg=null)
386386
$params['{attr}'] = isset($trans[$attrName]) ? $trans[$attrName] : $attrName;
387387

388388
foreach ($rule as $key => $value) {
389-
$params['{' . $key . '}'] = $value;
389+
$params['{' . $key . '}'] = is_array($value) ? implode(',', $value) : $value;
390390
}
391391

392392
return strtr($msg, $params);

0 commit comments

Comments
 (0)