Schema Validation

1.0.1Last update Dec 8, 2024
by@krishn404

This transformation involves modifying how a paragraph block type is handled in a schema-like structure by replacing its static configuration with a runtime validation function (isValidNode).

Before

const schema = {
blocks: {
paragraph: {
isVoid: false,
},
},
};

After

const isValidNode = (node: Node) => {
if (Element.isElement(node) && node.type === 'paragraph') {
return node.children.every(child => Text.isText(child));
}
return true;
};

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now