fix: Server error with invalid Prosemirror JSON should be validation error
This commit is contained in:
@@ -22,10 +22,16 @@ export default function TextLength({
|
|||||||
addAttributeOptions(target, propertyName, {
|
addAttributeOptions(target, propertyName, {
|
||||||
validate: {
|
validate: {
|
||||||
validLength(value: ProsemirrorData) {
|
validLength(value: ProsemirrorData) {
|
||||||
const text = ProsemirrorHelper.toPlainText(
|
let text;
|
||||||
Node.fromJSON(schema, value),
|
|
||||||
schema
|
try {
|
||||||
);
|
text = ProsemirrorHelper.toPlainText(
|
||||||
|
Node.fromJSON(schema, value),
|
||||||
|
schema
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error("Invalid data");
|
||||||
|
}
|
||||||
|
|
||||||
if (size(text) > max || size(text) < min) {
|
if (size(text) > max || size(text) < min) {
|
||||||
throw new Error(msg);
|
throw new Error(msg);
|
||||||
|
|||||||
Reference in New Issue
Block a user