Skip to content

Commit 1aaf750

Browse files
committed
Merge branch 'master' into 2.2-merge
# Conflicts: # bin/release.sh # bin/split.sh # src/validation/src/Concerns/FormatsMessages.php
2 parents db46bc5 + 7808ad0 commit 1aaf750

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/Concerns/ValidatesAttributes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function validateActiveUrl(string $attribute, $value): bool
5858

5959
if ($url = parse_url($value, PHP_URL_HOST)) {
6060
try {
61-
return count(dns_get_record($url, DNS_A | DNS_AAAA)) > 0;
61+
return count(dns_get_record($url . '.', DNS_A | DNS_AAAA)) > 0;
6262
} catch (Exception $e) {
6363
return false;
6464
}
@@ -630,7 +630,7 @@ public function validateIn(string $attribute, $value, array $parameters): bool
630630
return count(array_diff($value, $parameters)) === 0;
631631
}
632632

633-
return ! is_array($value) && in_array((string) $value, $parameters);
633+
return ! is_array($value) && in_array((string) $value, $parameters, true);
634634
}
635635

636636
/**

src/Rules/RequiredIf.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
*/
1212
namespace Hyperf\Validation\Rules;
1313

14+
use InvalidArgumentException;
15+
1416
class RequiredIf
1517
{
1618
/**
@@ -27,7 +29,11 @@ class RequiredIf
2729
*/
2830
public function __construct($condition)
2931
{
30-
$this->condition = $condition;
32+
if (! is_string($condition)) {
33+
$this->condition = $condition;
34+
} else {
35+
throw new InvalidArgumentException('The provided condition must be a callable or boolean.');
36+
}
3137
}
3238

3339
/**

tests/Cases/ValidationValidatorTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,10 @@ public function testValidateIn()
18231823
$v = new Validator($trans, ['name' => 0], ['name' => 'In:bar,baz']);
18241824
$this->assertFalse($v->passes());
18251825

1826+
$trans = $this->getIlluminateArrayTranslator();
1827+
$v = new Validator($trans, ['name' => 0], ['name' => 'In:00,000']);
1828+
$this->assertFalse($v->passes());
1829+
18261830
$v = new Validator($trans, ['name' => 'foo'], ['name' => 'In:foo,baz']);
18271831
$this->assertTrue($v->passes());
18281832

0 commit comments

Comments
 (0)