Review fixes

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-04-01 19:44:23 +04:00
parent e5b155a584
commit 821f66cc20
15 changed files with 255 additions and 39 deletions

View File

@@ -25,7 +25,11 @@ import (
// strings are allowed.
func ProseMirrorDocumentContent() ValidatorFunc {
return func(value any) *ValidationError {
s, ok := value.(string)
actualValue, isNil := dereferenceValue(value)
if isNil {
return nil
}
s, ok := actualValue.(string)
if !ok {
return newValidationError(ErrorCodeInvalidFormat, "value must be a string")
}

View File

@@ -31,6 +31,8 @@ func TestProseMirrorDocumentContent(t *testing.T) {
{"valid doc", validDoc, false},
{"plain text", "not json", true},
{"non-doc root", `{"type":"paragraph","content":[]}`, true},
{"nil value", nil, false},
{"nil *string", (*string)(nil), false},
{"non-string", 1, true},
}