forked from contentful/contentful-migration
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path56-add-items-validation.js
More file actions
51 lines (44 loc) · 1.26 KB
/
56-add-items-validation.js
File metadata and controls
51 lines (44 loc) · 1.26 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
module.exports = function (migration) {
migration.createContentType('contentModelA', {
name: 'Content Model A',
description: 'A content model for addItemsValidation'
})
migration.createContentType('contentModelB', {
name: 'Content Model B',
description: 'B content model for addItemsValidation'
})
migration.createContentType('contentModelC', {
name: 'Content Model C',
description: 'C content model for addItemsValidation'
})
const testModel = migration.createContentType('testModel', {
name: 'Test Model',
description: 'A test model for addItemsValidation'
})
testModel.createField('name').name('Name').type('Symbol').required(true)
testModel
.createField('tags')
.name('Tags')
.type('Array')
.items({
type: 'Symbol'
})
.addItemsValidation([{ unique: true }, { size: { min: 1, max: 5 } }])
testModel
.createField('skills')
.name('Skills')
.type('Array')
.items({
type: 'Symbol'
})
.addItemsValidation([{ size: { min: 1 } }])
testModel
.createField('relatedEntries')
.name('Related Entries')
.type('Array')
.items({
type: 'Link',
linkType: 'Entry'
})
.addItemsValidation([{ linkContentType: ['contentModelA', 'contentModelB'] }])
}