Skip to content

Commit 39c391b

Browse files
committed
refactor(validation): throw on invalid flag
1 parent 58b9b24 commit 39c391b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

packages/validation/src/Rules/IsJsonString.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
use Attribute;
88
use Tempest\Validation\Rule;
9+
use ValueError;
10+
11+
use const JSON_INVALID_UTF8_IGNORE;
912

1013
/**
1114
* Validates that the value is a valid JSON string.
@@ -31,6 +34,10 @@ public function isValid(mixed $value): bool
3134
}
3235

3336
if ($this->flags !== null) {
37+
if ($this->flags !== JSON_INVALID_UTF8_IGNORE) {
38+
throw new ValueError('Invalid JSON validation flags provided.');
39+
}
40+
3441
$arguments['flags'] = $this->flags;
3542
}
3643

0 commit comments

Comments
 (0)