Skip to content

Commit 3b53d0d

Browse files
author
Chris Hayes
committed
Merge pull request #14 from Jaspaul/master
Add Support For Laravel 5.0
2 parents 3a4100d + ed9d2d3 commit 3b53d0d

File tree

3 files changed

+40
-39
lines changed

3 files changed

+40
-39
lines changed

composer.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
],
1010
"require": {
1111
"php": ">=5.3.0",
12-
"illuminate/support": "~4.1",
13-
"illuminate/http": "~4.1",
14-
"illuminate/validation": "~4.1"
12+
"illuminate/support": "~5.0",
13+
"illuminate/http": "~5.0",
14+
"illuminate/validation": "~5.0",
15+
"illuminate/contracts": "~5.0"
1516
},
1617
"require-dev": {
1718
"mockery/mockery": "0.7.*"

src/Crhayes/Validation/ContextualValidator.php

+24-24
Original file line numberDiff line numberDiff line change
@@ -4,61 +4,61 @@
44

55
use Crhayes\Validation\Exceptions\ReplacementBindingException;
66
use Crhayes\Validation\Exceptions\ValidatorContextException;
7-
use Illuminate\Support\Contracts\MessageProviderInterface;
7+
use Illuminate\Contracts\Support\MessageProvider;
88
use Input;
99
use Validator;
1010

11-
abstract class ContextualValidator implements MessageProviderInterface
11+
abstract class ContextualValidator implements MessageProvider
1212
{
1313
const DEFAULT_KEY = 'default';
1414

1515
/**
1616
* Store the attributes we are validating.
17-
*
17+
*
1818
* @var array
1919
*/
2020
protected $attributes = array();
2121

2222
/**
2323
* Store the validation rules.
24-
*
24+
*
2525
* @var array
2626
*/
2727
protected $rules = array();
2828

2929
/**
3030
* Store any custom messages for validation rules.
31-
*
31+
*
3232
* @var array
3333
*/
3434
protected $messages = array();
3535

3636
/**
3737
* Store any contexts we are validating within.
38-
*
38+
*
3939
* @var array
4040
*/
4141
protected $contexts = array();
4242

4343
/**
4444
* Store replacement values for any bindings in our rules.
45-
*
45+
*
4646
* @var array
4747
*/
4848
protected $replacements = array();
4949

5050
/**
5151
* Store any validation messages generated.
52-
*
52+
*
5353
* @var array
5454
*/
5555
protected $errors = array();
5656

5757
/**
5858
* Our constructor will store the attributes we are validating, and
59-
* may also take as a second parameter the contexts within which
59+
* may also take as a second parameter the contexts within which
6060
* we are validating.
61-
*
61+
*
6262
* @param array $attributes
6363
* @param mixed $context
6464
*/
@@ -71,7 +71,7 @@ public function __construct($attributes = null, $context = null)
7171

7272
/**
7373
* Static shorthand for creating a new validator.
74-
*
74+
*
7575
* @param mixed $validator
7676
* @return Crhayes\Validation\GroupedValidator
7777
*/
@@ -83,7 +83,7 @@ public static function make($attributes = null, $context = null)
8383
/**
8484
* Stub method that can be extended by child classes.
8585
* Passes a validator object and allows for adding complex conditional validations.
86-
*
86+
*
8787
* @param \Illuminate\Validation\Validator $validator
8888
*/
8989
protected function addConditionalRules($validator) {}
@@ -113,13 +113,13 @@ public function getAttributes()
113113

114114
/**
115115
* Add a validation context.
116-
*
116+
*
117117
* @param array $context
118118
*/
119119
public function addContext($context)
120120
{
121121
$context = is_array($context) ? $context : array($context);
122-
122+
123123
$this->contexts = array_merge($this->contexts, $context);
124124

125125
return $this;
@@ -140,7 +140,7 @@ public function setContext($context)
140140

141141
/**
142142
* Retrieve the valiation context.
143-
*
143+
*
144144
* @return array
145145
*/
146146
public function getContexts()
@@ -150,7 +150,7 @@ public function getContexts()
150150

151151
/**
152152
* Bind a replacement value to a placeholder in a rule.
153-
*
153+
*
154154
* @param string $field
155155
* @param array $replacement
156156
* @return Crhayes\Validation\ContextualValidator
@@ -164,7 +164,7 @@ public function bindReplacement($field, array $replacement)
164164

165165
/**
166166
* Get a bound replacement by key.
167-
*
167+
*
168168
* @param string $key
169169
* @return array
170170
*/
@@ -175,7 +175,7 @@ public function getReplacement($key)
175175

176176
/**
177177
* Perform a validation check against our attributes.
178-
*
178+
*
179179
* @return boolean
180180
*/
181181
public function passes()
@@ -215,7 +215,7 @@ public function getMessageBag()
215215

216216
/**
217217
* Return any errors.
218-
*
218+
*
219219
* @return Illuminate\Support\MessageBag
220220
*/
221221
public function errors()
@@ -227,7 +227,7 @@ public function errors()
227227

228228
/**
229229
* Get the validaton rules within the context of the current validation.
230-
*
230+
*
231231
* @return array
232232
*/
233233
protected function getRulesInContext()
@@ -242,8 +242,8 @@ protected function getRulesInContext()
242242
{
243243
throw new ValidatorContextException(
244244
sprintf(
245-
"'%s' does not contain the validation context '%s'",
246-
get_called_class(),
245+
"'%s' does not contain the validation context '%s'",
246+
get_called_class(),
247247
$context
248248
)
249249
);
@@ -258,7 +258,7 @@ protected function getRulesInContext()
258258
/**
259259
* Spin through our contextual rules array and bind any replacement
260260
* values to placeholders within the rules.
261-
*
261+
*
262262
* @param array $rules
263263
* @return array
264264
*/
@@ -296,7 +296,7 @@ protected function bindReplacements($rules)
296296

297297
/**
298298
* Check if the current validation has a context.
299-
*
299+
*
300300
* @return boolean
301301
*/
302302
protected function hasContext()

src/Crhayes/Validation/GroupedValidator.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@
33
namespace Crhayes\Validation;
44

55
use Crhayes\Validation\Exceptions\MissingValidatorException;
6-
use Illuminate\Support\Contracts\MessageProviderInterface;
6+
use Illuminate\Contracts\Support\MessageProvider;
77

88
class GroupedValidator
99
{
1010
/**
1111
* An array of Validator objects we will spin through
1212
* when running our grouped validation.
13-
*
13+
*
1414
* @var array
1515
*/
1616
protected $validators = array();
1717

1818
/**
1919
* An array of errors returned from all of the validators.
20-
*
20+
*
2121
* @var array
2222
*/
2323
protected $errors = array();
2424

2525
/**
2626
* Create a new GroupedValidator, with the option of specifying
2727
* either a single validator object or an array of validators.
28-
*
28+
*
2929
* @param mixed $validator
3030
*/
3131
public function __construct($validator = array())
@@ -35,7 +35,7 @@ public function __construct($validator = array())
3535

3636
/**
3737
* Static shorthand for creating a new grouped validator.
38-
*
38+
*
3939
* @param mixed $validator
4040
* @return Crhayes\Validation\GroupedValidator
4141
*/
@@ -47,21 +47,21 @@ public static function make($validator = array())
4747
/**
4848
* Add a validator to spin through. Accepts either a single
4949
* Validator object or an array of validators.
50-
*
50+
*
5151
* @param mixed $validator
5252
*/
53-
public function addValidator(MessageProviderInterface $validator)
53+
public function addValidator(MessageProvider $validator)
5454
{
5555
$validator = is_array($validator) ? $validator : array($validator);
56-
56+
5757
$this->validators = array_merge($this->validators, $validator);
5858

5959
return $this;
6060
}
6161

6262
/**
6363
* Perform a check to see if all of the validators have passed.
64-
*
64+
*
6565
* @return boolean
6666
*/
6767
public function passes()
@@ -78,10 +78,10 @@ public function passes()
7878

7979
return (count($this->errors)) ? false : true;
8080
}
81-
81+
8282
/**
8383
* Perform a check to see if any of the validators have failed.
84-
*
84+
*
8585
* @return boolean
8686
*/
8787
public function fails()
@@ -91,7 +91,7 @@ public function fails()
9191

9292
/**
9393
* Return the combined errors from all validators.
94-
*
94+
*
9595
* @return Illuminate\Support\MessageBag
9696
*/
9797
public function errors()

0 commit comments

Comments
 (0)