Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 9, 2021
2 parents bd490fe + 784f8ff commit 2584678
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG-6.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@
### Changed
- Improve cookie encryption ([#33662](https://github.com/laravel/framework/pull/33662))

This change will invalidate all existing cookies. Please see [this security bulletin](https://blog.laravel.com/laravel-cookie-security-releases) for more information.


## [v6.18.26 (2020-07-21)](https://github.com/laravel/framework/compare/v6.18.25...v6.18.26)

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Application extends Container implements ApplicationContract, CachesConfig
*
* @var string
*/
const VERSION = '8.31.0';
const VERSION = '8.32.0';

/**
* The base path for the Laravel installation.
Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ public function validateRequiredIf($attribute, $value, $parameters)

[$values, $other] = $this->parseDependentRuleParameters($parameters);

if (in_array($other, $values)) {
if (in_array($other, $values, is_bool($other))) {
return $this->validateRequired($attribute, $value);
}

Expand Down Expand Up @@ -1490,7 +1490,7 @@ public function validateExcludeIf($attribute, $value, $parameters)

[$values, $other] = $this->parseDependentRuleParameters($parameters);

return ! in_array($other, $values);
return ! in_array($other, $values, is_bool($other));
}

/**
Expand All @@ -1507,7 +1507,7 @@ public function validateExcludeUnless($attribute, $value, $parameters)

[$values, $other] = $this->parseDependentRuleParameters($parameters);

return in_array($other, $values);
return in_array($other, $values, is_bool($other));
}

/**
Expand Down Expand Up @@ -1596,7 +1596,7 @@ public function validateRequiredUnless($attribute, $value, $parameters)

[$values, $other] = $this->parseDependentRuleParameters($parameters);

if (! in_array($other, $values)) {
if (! in_array($other, $values, is_bool($other))) {
return $this->validateRequired($attribute, $value);
}

Expand Down
66 changes: 66 additions & 0 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1096,10 +1096,34 @@ public function testRequiredIf()
$v = new Validator($trans, ['foo' => true], ['bar' => 'required_if:foo,false']);
$this->assertTrue($v->passes());

$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['foo' => true], ['bar' => 'required_if:foo,null']);
$this->assertTrue($v->passes());

$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['foo' => 0], ['bar' => 'required_if:foo,0']);
$this->assertTrue($v->fails());

$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['foo' => '0'], ['bar' => 'required_if:foo,0']);
$this->assertTrue($v->fails());

$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['foo' => 1], ['bar' => 'required_if:foo,1']);
$this->assertTrue($v->fails());

$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['foo' => '1'], ['bar' => 'required_if:foo,1']);
$this->assertTrue($v->fails());

$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['foo' => true], ['bar' => 'required_if:foo,true']);
$this->assertTrue($v->fails());

$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['foo' => false], ['bar' => 'required_if:foo,false']);
$this->assertTrue($v->fails());

// error message when passed multiple values (required_if:foo,bar,baz)
$trans = $this->getIlluminateArrayTranslator();
$trans->addLines(['validation.required_if' => 'The :attribute field is required when :other is :value.'], 'en');
Expand Down Expand Up @@ -1138,6 +1162,26 @@ public function testRequiredUnless()
$v = new Validator($trans, ['foo' => false], ['bar' => 'required_unless:foo,true']);
$this->assertTrue($v->fails());

$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['foo' => true], ['bar' => 'required_unless:foo,null']);
$this->assertTrue($v->fails());

$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['foo' => '0'], ['bar' => 'required_unless:foo,0']);
$this->assertTrue($v->passes());

$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['foo' => 0], ['bar' => 'required_unless:foo,0']);
$this->assertTrue($v->passes());

$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['foo' => '1'], ['bar' => 'required_unless:foo,1']);
$this->assertTrue($v->passes());

$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['foo' => 1], ['bar' => 'required_unless:foo,1']);
$this->assertTrue($v->passes());

// error message when passed multiple values (required_unless:foo,bar,baz)
$trans = $this->getIlluminateArrayTranslator();
$trans->addLines(['validation.required_unless' => 'The :attribute field is required unless :other is in :values.'], 'en');
Expand Down Expand Up @@ -5406,6 +5450,20 @@ public function providesPassingExcludeIfData()
'has_appointment' => false,
],
],
[
[
'has_appointment' => ['nullable', 'bool'],
'appointment_date' => ['exclude_if:has_appointment,null', 'required', 'date'],
],
[
'has_appointment' => true,
'appointment_date' => '2021-03-08',
],
[
'has_appointment' => true,
'appointment_date' => '2021-03-08',
],
],
[
[
'has_appointment' => ['required', 'bool'],
Expand Down Expand Up @@ -5740,6 +5798,14 @@ public function testExcludeUnless()
);
$this->assertTrue($validator->fails());
$this->assertSame(['mouse' => ['validation.required']], $validator->messages()->toArray());

$validator = new Validator(
$this->getIlluminateArrayTranslator(),
['foo' => true, 'bar' => 'baz'],
['foo' => 'nullable', 'bar' => 'exclude_unless:foo,null']
);
$this->assertTrue($validator->passes());
$this->assertSame(['foo' => true], $validator->validated());
}

public function testExcludeWithout()
Expand Down

0 comments on commit 2584678

Please sign in to comment.