Skip to content

Commit 1c62b45

Browse files
committed
Revert "Add option to check for value presence, while allowing empty values"
This reverts commit f271f20.
1 parent f271f20 commit 1c62b45

File tree

2 files changed

+1
-23
lines changed

2 files changed

+1
-23
lines changed

src/Validator.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ public function __construct(
3434
* Note: strings are trimmed prior to check, and values that empty() would return true for (like '0') are considered
3535
* to be present (because we check strlen(trim($value))).
3636
*/
37-
public function present(
38-
string $field_name,
39-
bool $allow_empty = false,
40-
): bool
37+
public function present(string $field_name): bool
4138
{
4239
if (empty($field_name)) {
4340
throw new InvalidArgumentException(
@@ -49,10 +46,6 @@ public function present(
4946
return $this->failPresenceValidation($field_name);
5047
}
5148

52-
if ($allow_empty && empty($this->field_values[$field_name])) {
53-
return true;
54-
}
55-
5649
if (is_string($this->field_values[$field_name])) {
5750
if (mb_strlen(trim($this->field_values[$field_name])) > 0) {
5851
return true;

test/src/PresenceValidatorTest.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,6 @@ public function testPass()
4242
$this->assertCount(0, $name_errors);
4343
}
4444

45-
public function testPassAllowEmpty()
46-
{
47-
$validator = new Validator($this->connection, 'writers', null, null, ['name' => '']);
48-
49-
$is_present = $validator->present('name', true);
50-
51-
$this->assertTrue($is_present);
52-
$this->assertFalse($validator->hasErrors());
53-
54-
$name_errors = $validator->getFieldErrors('name');
55-
56-
$this->assertIsArray($name_errors);
57-
$this->assertCount(0, $name_errors);
58-
}
59-
6045
/**
6146
* Test validation failure.
6247
*/

0 commit comments

Comments
 (0)