Skip to content

Commit 0172fe8

Browse files
Update README.md
1 parent 226a18b commit 0172fe8

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,16 +310,11 @@ $errors = $validator->errors();
310310
### Set Custom Rules
311311

312312
We can set predefined/custom rules for data validation.
313-
if custom rule return `true` that means data is valid and if it will return `false` that means data is invalid.
313+
Custom rules take a callback function with one argument. If custom rule return `true` that means data is valid and if it will return `false` that means data is invalid.
314314

315315
```php
316316
// Set validation rules
317317
$validator = Validator::make([
318-
'name' => [
319-
'required' => true,
320-
'not_null' => true,
321-
'string' => true
322-
],
323318
'email' => [
324319
'required' => true,
325320
'not_null' => true,
@@ -336,6 +331,13 @@ $validator = Validator::make([
336331
// Set your own custom rules
337332
'available' => is_available($value),
338333
]
334+
],
335+
[
336+
// Set error messages for custom rules
337+
'email' => [
338+
'blocked' => 'this email address is blocked',
339+
'available' => 'this email address is already registered',
340+
]
339341
]);
340342
```
341343

0 commit comments

Comments
 (0)