You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+37-40Lines changed: 37 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,40 +30,40 @@ This package makes validation rules defined in laravel work client-side by conve
30
30
### Installation
31
31
32
32
Require `bllim/laravalid` in composer.json and run `composer update`.
33
-
33
+
```json
34
34
{
35
35
"require": {
36
-
"laravel/framework": "5.1.*", //or "5.0.*"
36
+
"laravel/framework": "5.2.*", //or "5.0.*"
37
37
...
38
38
"bllim/laravalid": "*"
39
39
}
40
40
...
41
41
}
42
-
42
+
```
43
43
> **Note:** For **Laravel 4** use `laravel4` branch like as `"bllim/laravalid": "dev-laravel4"`
44
44
45
45
Composer will download the package. After the package is downloaded, open `config/app.php` and add the service provider and alias as below:
46
46
```php
47
47
'providers' => array(
48
48
...
49
-
'Bllim\Laravalid\LaravalidServiceProvider',
49
+
Bllim\Laravalid\LaravalidServiceProvider::class,
50
50
),
51
51
```
52
52
```php
53
53
'aliases' => array(
54
54
...
55
-
'HTML' => 'Collective\Html\HtmlFacade::class', // if not exists add for html too
56
-
'Form' => 'Bllim\Laravalid\Facade',
55
+
'HTML' => Collective\Html\HtmlFacade::class, // if not exists add for html too
56
+
'Form' => Bllim\Laravalid\Facade::class,
57
57
),
58
58
```
59
59
60
60
Also you need to publish configuration file and assets by running the following Artisan commands.
61
-
```php
61
+
```bash
62
62
$ php artisan vendor:publish
63
63
```
64
64
65
65
### Configuration
66
-
After publishing configuration file, you can find it in config/laravalid folder. Configuration parameters are as below:
66
+
After publishing configuration file, you can find it in `config` folder as `laravalid.php` file. Configuration parameters are as below:
67
67
68
68
| Parameter | Description | Values |
69
69
|-----------|-------------|--------|
@@ -73,7 +73,7 @@ After publishing configuration file, you can find it in config/laravalid folder.
73
73
74
74
### Usage
75
75
76
-
The package uses laravel Form Builder to make validation rules work for both sides. Therefore you should use Form Builder. While opening form by using Form::open you can give $rules as second parameter:
76
+
The package uses laravel Form Builder to make validation rules work for both sides. Therefore you should use Form Builder. While opening form by using `Form::open` you can give `$rules` as second parameter:
@@ -82,7 +82,7 @@ The package uses laravel Form Builder to make validation rules work for both sid
82
82
Form::text('birthdate');
83
83
Form::close(); // don't forget to close form, it reset validation rules
84
84
```
85
-
Also if you don't want to struggle with $rules at view files, you can set it in Controller or route with or without form name by using Form::setValidation($rules, $formName). If you don't give form name, this sets rules for first Form::open
85
+
Also if you don't want to struggle with `$rules` at view files, you can set it in `Controller` or route with or without form name by using `Form::setValidation($rules, $formName)`. If you don't give form name, this sets rules for first `Form::open`
@@ -93,19 +93,19 @@ Also if you don't want to struggle with $rules at view files, you can set it in
93
93
// some form inputs
94
94
Form::close();
95
95
```
96
-
For rules which is related to input type in laravel (such as max, min), the package looks for other given rules to understand which type is input. If you give integer or numeric as rule with max, min rules, the package assume input is numeric and convert to data-rule-max instead of data-rule-maxlength.
96
+
For rules which is related to input type in laravel (such as `max`, `min`), the package looks for other given rules to understand which type is input. If you give integer or numeric as rule with `max`, `min` rules, the package assume input is numeric and convert to `data-rule-max` instead of `data-rule-maxlength`.
97
97
```php
98
98
$rules = ['age' => 'numeric|max'];
99
99
```
100
-
The converter assume input is string by default. File type is not supported yet.
100
+
The converter assume input is `string` by default. File type is also supported.
101
101
102
102
**Validation Messages**
103
103
104
-
Converter uses validation messages of laravel (app/lang/en/validation.php) by default for client-side too. If you want to use jquery validation messages, you can set useLaravelMessages, false in config file of package which you copied to your config dir.
104
+
Converter uses validation messages of laravel (`resources/lang/en/validation.php`) by default for client-side too. If you want to use jquery validation messages, you can set `useLaravelMessages`, false in config file of package which you copied to your config dir.
105
105
106
106
#### Plugins
107
107
**Jquery Validation**
108
-
While using Jquery Validation as html/js validation plugin, you should include jquery.validate.laravalid.js in your views, too. After assets published, it will be copied to your public folder. The last thing you should do at client side is initializing jquery validation plugin as below:
108
+
While using Jquery Validation as html/js validation plugin, you should include `jquery.validate.laravalid.js` in your views, too. After assets published, it will be copied to your public folder. The last thing you should do at client side is initializing jquery validation plugin as below:
109
109
```html
110
110
<scripttype="text/javascript">
111
111
$('form').validate({onkeyup:false}); //while using remote validation, remember to set onkeyup false
return ['valid' => false, 'messages' => 'Seriously dude, what kind of input is this?'];
190
187
});
191
-
192
188
```
189
+
193
190
Second, you can create your own converter (which extends baseconverter or any current plugin converter) in `Bllim\Laravalid\Converter\` namespace and change plugin configuration in config file with your own plugin name.
194
191
195
-
> **Note:** If you are creating a converter for some existed html/js plugin please create it in `converters` folder and send a pull-request.
192
+
> **Note:** If you are creating a converter for some existed html/js plugin please create it in `Converter` folder and send a pull-request.
196
193
197
194
### Plugins and Supported Rules
198
195
**Jquery Validation**
199
-
To use Jquery Validation, change plugin to `JqueryValidation` in config file and import jquery, jquery-validation and **jquery.validation.laravel.js** in views.
196
+
To use Jquery Validation, change plugin to `JqueryValidation` in config file and import `jquery`, `jquery-validation` and **jquery.validate.laravalid.js** in views.
200
197
201
198
202
199
| Rules | Jquery Validation |
203
200
| ---------------|:----------------:|
204
201
| Accepted | - |
205
-
| Active URL |-|
206
-
| After (Date) |-|
202
+
| Active URL |`+`|
203
+
| After (Date) |`+`|
207
204
| Alpha |`+`|
208
205
| Alpha Dash | - |
209
-
| Alpha Numeric |-|
206
+
| Alpha Numeric |`+`|
210
207
| Array | - |
211
-
| Before (Date) |-|
208
+
| Before (Date) |`+`|
212
209
| Between |`+`|
213
210
| Boolean | - |
214
211
| Confirmed | - |
215
212
| Date |`+`|
216
213
| Date Format | - |
217
-
| Different |-|
214
+
| Different |`+`|
218
215
| Digits | - |
219
216
| Digits Between | - |
220
217
| E-Mail |`+`|
221
218
| Exists (Database) |`+`|
222
-
| Image (File) |-|
219
+
| Image (File) |`+`|
223
220
| In | - |
224
-
| Integer |-|
221
+
| Integer |`+`|
225
222
| IP Address |`+`|
226
223
| Max |`+`|
227
-
| MIME Types |-|
224
+
| MIME Types |`+`|
228
225
| Min |`+`|
229
226
| Not In | - |
230
227
| Numeric |`+`|
231
228
| Regular Expression |`+`|
232
229
| Required |`+`|
233
230
| Required If | - |
234
-
| Required With |-|
231
+
| Required With |`+`|
235
232
| Required With All | - |
236
-
| Required Without |-|
233
+
| Required Without |`+`|
237
234
| Required Without All | - |
238
235
| Same |`+`|
239
236
| Size | - |
@@ -248,14 +245,13 @@ To use Jquery Validation, change plugin to `JqueryValidation` in config file and
248
245
You can fork and contribute to development of the package. All pull requests is welcome.
249
246
250
247
**Convertion Logic**
251
-
Package converts rules by using converters (in src/converters). It uses Converter class of chosen plugin which extends BaseConverter/Converter class.
248
+
Package converts rules by using converters (in `src/Bllim/Laravalid/Converter`). It uses `Converter` class of chosen plugin which extends `Converter/Base/Converter` class.
252
249
You can look at existed methods and plugins to understand how it works. Explanation will be ready, soon.
253
250
254
251
### Known issues
255
252
- Some rules are not supported for now
256
253
257
254
### TODO
258
-
- Test script
259
255
- Support unsupported rules
260
256
- Improve doc
261
257
- Comment code
@@ -265,6 +261,7 @@ You can look at existed methods and plugins to understand how it works. Explanat
265
261
-@phpspider
266
262
-@jannispl
267
263
-@rene-springmann
264
+
-@nthachus
268
265
269
266
and [more](https://github.com/bllim/laravalid/graphs/contributors)
0 commit comments