Skip to content

Commit b57e2b0

Browse files
authored
Merge branch 'laravel:9.x' into 9.x
2 parents 685b0f1 + c3ed678 commit b57e2b0

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

src/Illuminate/Validation/Concerns/ValidatesAttributes.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,19 @@ public function validateLte($attribute, $value, $parameters)
11581158
return $this->getSize($attribute, $value) <= $this->getSize($attribute, $comparedToValue);
11591159
}
11601160

1161+
/**
1162+
* Validate that an attribute is lowercase.
1163+
*
1164+
* @param string $attribute
1165+
* @param mixed $value
1166+
* @param array<int, int|string> $parameters
1167+
* @return bool
1168+
*/
1169+
public function validateLowercase($attribute, $value, $parameters)
1170+
{
1171+
return Str::lower($value) === $value;
1172+
}
1173+
11611174
/**
11621175
* Validate the MIME type of a file is an image MIME type.
11631176
*

tests/Validation/ValidationValidatorTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,6 +1803,33 @@ public function testGreaterThan()
18031803
$this->assertTrue($v->passes());
18041804
}
18051805

1806+
public function testLowercase()
1807+
{
1808+
$trans = $this->getIlluminateArrayTranslator();
1809+
$v = new Validator($trans, [
1810+
'lower' => 'lowercase',
1811+
'mixed' => 'MixedCase',
1812+
'upper' => 'UPPERCASE',
1813+
'lower_multibyte' => 'carácter multibyte',
1814+
'mixed_multibyte' => 'carÁcter multibyte',
1815+
'upper_multibyte' => 'CARÁCTER MULTIBYTE',
1816+
], [
1817+
'lower' => 'lowercase',
1818+
'mixed' => 'lowercase',
1819+
'upper' => 'lowercase',
1820+
'lower_multibyte' => 'lowercase',
1821+
'mixed_multibyte' => 'lowercase',
1822+
'upper_multibyte' => 'lowercase',
1823+
]);
1824+
1825+
$this->assertSame([
1826+
'mixed',
1827+
'upper',
1828+
'mixed_multibyte',
1829+
'upper_multibyte',
1830+
], $v->messages()->keys());
1831+
}
1832+
18061833
public function testLessThan()
18071834
{
18081835
$trans = $this->getIlluminateArrayTranslator();

0 commit comments

Comments
 (0)