-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(validation): add validation schema for rich text nodes (#152)
- Loading branch information
Phoebe Schmidt
authored
Nov 28, 2018
1 parent
99b4976
commit 3b9efdf
Showing
3 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Example of setting `validations` for rich text fields of a content type. | ||
module.exports = function (migration) { | ||
const myRichTextCT = migration.createContentType('myContentTypeWithRichText').name('MyContentTypeWithRichText'); | ||
myRichTextCT | ||
.createField('richText') | ||
.name('Text') | ||
.type('RichText') | ||
.validations([ | ||
{ | ||
nodes: { | ||
'embedded-entry-block': [ | ||
{ | ||
size: { | ||
min: 1, | ||
max: 4 | ||
} | ||
}, | ||
{ | ||
linkContentType: ['markdownContentType'] | ||
} | ||
], | ||
'embedded-entry-inline': [ | ||
{ | ||
size: { | ||
min: 10, | ||
max: 20 | ||
}, | ||
message: 'this is a custom error for number of embedded inline entries' | ||
}, | ||
{ | ||
linkContentType: ['parent'], | ||
message: 'we only accept parent' | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
enabledNodeTypes: [ | ||
'heading-1', | ||
'heading-2', | ||
'heading-3', | ||
'heading-4', | ||
'heading-5', | ||
'ordered-list', | ||
'unordered-list', | ||
'hr', | ||
'blockquote', | ||
'embedded-entry-block', | ||
'embedded-asset-block', | ||
'hyperlink', | ||
'entry-hyperlink', | ||
'asset-hyperlink', | ||
'embedded-entry-inline' | ||
], | ||
message: | ||
'Only heading 1, heading 2, heading 3, heading 4, heading 5, ordered list, unordered list, horizontal rule, quote, block entry, asset, link to Url, link to entry, link to asset, and inline entry nodes are allowed' | ||
} | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters