We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 133d543 commit ef37df1Copy full SHA for ef37df1
resources/lang/en/messages.php
@@ -1,6 +1,7 @@
1
<?php
2
3
return [
4
+ 'must-be-string' => ':Attribute must be a string or null',
5
'error-message' => 'JSON validaton failed for :attribute.',
6
'detailed-error-message' => 'JSON validation failed for :attribute. :details',
7
];
src/Rules/BaseRule.php
@@ -27,6 +27,12 @@ public function __construct(
27
*/
28
public function validate(string $attribute, mixed $value, Closure $fail): void
29
{
30
+ $value ??= '';
31
+
32
+ if (! is_string($value)) {
33
+ $fail('json-schema::messages.must-be-string')->translate(['attribute' => $attribute]);
34
+ }
35
36
$result = $this->schemaValidator->validate($this->determineSchemaName(), $value);
37
38
if ($result->failed()) {
0 commit comments