forked from contentful/contentful-migration
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path22-create-rich-text-field-with-validation.js
More file actions
78 lines (78 loc) · 2.36 KB
/
22-create-rich-text-field-with-validation.js
File metadata and controls
78 lines (78 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// 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'
}
],
'embedded-resource-block': {
validations: [],
allowedResources: [
{
type: 'Contentful:Entry',
source: 'crn:contentful:::content:spaces/another-space',
contentTypes: ['contentType1', 'contentType2', 'contentType3']
}
]
}
}
},
{
enabledMarks: ['bold', 'italic', 'underline', 'code', 'superscript', 'subscript', 'strikethrough'],
message: 'Only bold, italic, underline, code, superscript, subscript and strikethrough marks are allowed'
},
{
enabledNodeTypes: [
'heading-1',
'heading-2',
'heading-3',
'heading-4',
'heading-5',
'heading-6',
'ordered-list',
'unordered-list',
'hr',
'blockquote',
'embedded-entry-block',
'embedded-asset-block',
'table',
'hyperlink',
'entry-hyperlink',
'asset-hyperlink',
'embedded-entry-inline',
'embedded-resource-block'
],
message:
'Only heading 1, heading 2, heading 3, heading 4, heading 5, heading 6, ordered list, unordered list, horizontal rule, quote, block entry, asset, table, block embedded resource, asset, link to Url, link to entry, link to asset, and inline entry nodes are allowed'
}
])
}