Skip to content

Commit f6b7701

Browse files
Merge pull request #309 from GrahamCampbell/allowed-values
Validation exception list allowed values
2 parents b908790 + ac6295b commit f6b7701

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/Validator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ public function allowedValues(array $choices)
117117
{
118118
return $this->assertCallback(
119119
function ($value) use ($choices) {
120-
return in_array($value, $choices);
120+
return in_array($value, $choices, true);
121121
},
122-
'is not an allowed value'
122+
sprintf('is not one of [%s]', implode(', ', $choices))
123123
);
124124
}
125125

tests/Dotenv/DotenvTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,13 @@ public function testDotenvAllowedValues()
182182
* @depends testDotenvLoadsServerGlobals
183183
*
184184
* @expectedException \Dotenv\Exception\ValidationException
185-
* @expectedExceptionMessage One or more environment variables failed assertions: FOO is not an allowed value.
185+
* @expectedExceptionMessage One or more environment variables failed assertions: FOO is not one of [buzz, buz].
186186
*/
187187
public function testDotenvProhibitedValues()
188188
{
189189
$dotenv = Dotenv::create($this->fixturesFolder);
190190
$dotenv->load();
191-
$dotenv->required('FOO')->allowedValues(['buzz']);
191+
$dotenv->required('FOO')->allowedValues(['buzz', 'buz']);
192192
}
193193

194194
/**

tests/Dotenv/ValidatorBooleanTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function invalidBooleanValuesDataProvider()
8585
/**
8686
* @dataProvider invalidBooleanValuesDataProvider
8787
* @expectedException Dotenv\Exception\ValidationException
88+
* @expectedExceptionMessage One or more environment variables failed assertions: INVALID_
8889
*/
8990
public function testCanInvalidateNonBooleans($boolean)
9091
{

0 commit comments

Comments
 (0)