@@ -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")
|
||||
}
|
||||
|
||||
@@ -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},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user