@@ -21,7 +21,6 @@ A validation library for the Slim Framework. It internally uses [Respect/Validat
21
21
- [ JSON requests] ( #json-requests )
22
22
- [ XML requests] ( #xml-requests )
23
23
- [ Translate errors] ( #translate-errors )
24
- - [ Use templates] ( #use-templates )
25
24
- [ Testing] ( #testing )
26
25
- [ Contributing] ( #contributing )
27
26
- [ Credits] ( #credits )
@@ -63,7 +62,7 @@ $app->get('/api/myEndPoint',function ($req, $res, $args) {
63
62
//There are errors, read them
64
63
$errors = $req->getAttribute('errors');
65
64
66
- /* $errors contain :
65
+ /* $errors contains :
67
66
array(
68
67
'username' => array(
69
68
'"davidepastore" must have a length between 1 and 10',
@@ -108,7 +107,7 @@ $app->get('/foo', function ($req, $res, $args) {
108
107
//There are errors, read them
109
108
$errors = $req->getAttribute('errors');
110
109
111
- /* $errors contain :
110
+ /* $errors contains :
112
111
array(
113
112
'username' => array(
114
113
'"davidepastore" must have a length between 1 and 10',
@@ -156,7 +155,7 @@ $app->get('/foo/{param}', function ($req, $res, $args) {
156
155
//There are errors, read them
157
156
$errors = $req->getAttribute('errors');
158
157
159
- /* $errors contain :
158
+ /* $errors contains :
160
159
array(
161
160
'param' => array(
162
161
'"wrong" must be numeric',
@@ -322,29 +321,6 @@ $middleware = new \DavidePastore\Slim\Validation\Validation($validators, $transl
322
321
$app->run();
323
322
```
324
323
325
- ### Use templates
326
-
327
- With the third parameter you can specify to use [ templates] [ custom-messages ] .
328
-
329
- ``` php
330
- use Respect\Validation\Validator as v;
331
-
332
- $app = new \Slim\App();
333
-
334
- //Create the validators
335
- $usernameValidator = v::alnum()->noWhitespace()->length(1, 10);
336
- $ageValidator = v::numeric()->positive()->between(1, 20);
337
- $validators = array(
338
- 'hostname' => v::regex('/^[a-zA-Z]([-.a-zA-Z0-9]{0,61}[a-zA-Z0-9]){0,1}$/')->setTemplate('Hostname {{name}} is not valid')
339
- );
340
-
341
- $middleware = new \DavidePastore\Slim\Validation\Validation($validators, null, array('useTemplate' => true));
342
-
343
- // Register middleware for all routes or only for one...
344
-
345
- $app->run();
346
- ```
347
-
348
324
349
325
## Testing
350
326
0 commit comments