diff --git a/packages/rich-text-types/src/validator/node.ts b/packages/rich-text-types/src/validator/node.ts index bffc5ab9..2e9fd96a 100644 --- a/packages/rich-text-types/src/validator/node.ts +++ b/packages/rich-text-types/src/validator/node.ts @@ -29,10 +29,7 @@ export type ValidateData = (data: T['data'], path: Path) => Vali export const VOID_CONTENT: GetContentRule = []; export class NodeAssertion { - constructor( - private contentRule: GetContentRule, - private validateData?: ValidateData, - ) {} + constructor(private contentRule: GetContentRule, private validateData?: ValidateData) {} assert(node: T, path: Path): ValidationError[] { const $ = new ObjectAssertion(node, path); @@ -111,6 +108,10 @@ export class EntityLinkAssertion< const $ = new ObjectAssertion(data, path); if ($.object('target')) { + const target$ = new ObjectAssertion(data.target, path.of('target')); + + target$.noAdditionalProperties(['sys']); + const sys$ = new ObjectAssertion(data.target.sys, path.of('target').of('sys')); if (sys$.object()) { @@ -126,7 +127,7 @@ export class EntityLinkAssertion< } } - $.catch(...sys$.errors); + $.catch(...target$.errors, ...sys$.errors); } $.noAdditionalProperties(['target']);