Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit 45e9539

Browse files
committed
Adding docs on localized messages
1 parent cc4bd34 commit 45e9539

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This package makes validation rules defined in Laravel work in the client by con
88
- [Feature Overview](#feature-overview)
99
- [Installation](#installation)
1010
- [Configuration](#configuration)
11+
- [Validation messages](#validation-messages)
1112
- [Usage](#usage)
1213
- [With Ardent](#usage-with-ardent)
1314
- [Extending](#extending)
@@ -72,6 +73,19 @@ After publishing configuration file, you can find it in config/laravalid folder.
7273
| useLaravelMessages | If it is true, laravel validation messages are used in client side otherwise messages of chosen plugin are used | true/false |
7374
| route | Route name for remote validation | Any route name (default: laravalid) |
7475

76+
#### Validation Messages
77+
If you set `useLaravelMessages` to `true`, you're able to use (Laravel's Localization package)[l10n] to generate validation messages. To do so, follow the [docs][l10n] to get the package configured (by setting your default/fallback/current locales). Then, create a folder for each locale (as the docs says) and create a `validation.php` file for each one. Inside those files you'll set a message for each rule name, as follows:
78+
```php
79+
<?php return [
80+
'required' => 'This is a required field',
81+
'min' => [
82+
'string' => 'This is too short',
83+
'number' => 'This is too low',
84+
]
85+
//...
86+
];
87+
```
88+
7589
### Usage
7690

7791
The package uses Laravel Form Builder to make validation rules work for both sides. While opening a form by using `Form::open` you can pass the $rules as the second parameter:
@@ -277,3 +291,5 @@ See the [project's releases](https://github.com/laravel-ardent/laravalid/release
277291

278292
### License
279293
Licensed under the MIT License
294+
295+
[l10n]:http://laravel.com/docs/5.1/localizationl

0 commit comments

Comments
 (0)