Here is a list of supported validations.
Whenever trying to set a property which doesn't exist, and we couldn't offer any suggestion to use as a replacement.
Example:
field.fdskljhdf('Ctrl + arm')
Whenever trying to set a property which doesn't exist, and we could offer a suggestion to use as a replacement.
Example:
field.nmae('First name')
Whenever setting a value to a property which is not matching the expected type.
Example:
field.name(true)
Whenever trying to move a field with the wrong type for the field id.
Example:
contentType.moveField(3).toTheTop()
Whenever trying to move a field relative to itself.
Example:
contentType.moveField('name').afterField('name')
Whenever trying to move a field relative to another with an invalid movement.
Example:
contentType.moveField('name').xyz('surname')
Whenever trying to move a field relative to another with an invalid movement but we can provide a suggestion.
Example:
contentType.moveField('name').after('surname')
While evaluating your migration script we validate that the actions you want to perform on content types and fields aren't wrong in any sense.
These validations are bound to the entity type and action on which they ocurred. Therefore the error keys are scoped to it
and have a layout of {entity}.{action}.{validation name}
.
Whenever trying to create twice the same field.
Example:
contentType.createField('name').name('First name')
contentType.createField('name').name('Last name')
Whenever trying to create a field on a non-existing content type.
Example:
// While no `inexistent` content type exists in the target space
migration.editContentType('inexistent').createField('foo')
Whenever trying to delete a field twice.
Example:
contentType.deleteField('name')
contentType.deleteField('name')
Whenever trying to delete a field which doesn't exist.
Example:
contentType.createField('name')
// ...
contentType.deleteField('nmae')
Whenever trying to delete a field of a content type which doesn't exist.
Example:
// While no `inexistent` content type exists in the target space
migration.editContentType('inexistent').deleteField('foo')
Whenever trying to edit a field which doesn't exist.
Example:
contentType.createField('name')
// ...
contentType.editField('nmae')
Whenever trying to update a field after it has been deleted.
Example:
contentType.deleteField('name')
contentType.editField('name')
Whenever trying to update a field on a non-existing content type.
Example:
// While no `inexistent` content type exists in the target space
migration.editContentType('inexistent').editField('foo')
Whenever trying to create a content type twice.
Example:
migration.createContentType('author').name('Author')
// ...
migration.createContentType('author').name('Editor')
Whenever trying to move a field which was already deleted.
Example:
contentType.deleteField('name')
// ...
contentType.moveField('name').toTheTop()
Whenever trying to move a field which doesn't exists.
Whenever trying to move a field which was already moved.
Example:
contentType.moveField('name').toTheTop()
contentType.moveField('name').toTheBottom()
Whenever you try to move a field on a non existing content type.
Whenever you try to move field relative to another one which doesn't exist.
Example:
contentType.moveField('name').afterField('somefield-that-doesnt-exist')
Whenever you try to move a field relative to another one which has been already deleted.
Example:
contentType.deleteField('surname')
contentType.moveField('name').afterField('surname')
Whenever trying to create a content type which already exists in the target space.
Example:
// While `author` already exists in the target space
migration.createContentType('author').name('Author')
Whenever trying to edit a content type which doesn't exist currently. (i.e. is created later in the migration)
Example:
// While no `inexistent` content type exists in the target space
migration.editContentType('inexistent')
migration.createContentType('inexistent')
Whenever trying to create or edit a field of a content type which hasn't yet been created.
Example:
author.createField('fullName').name('Full name')
const author = migration.createContentType('author').name('Author')
Some other validation errors pop up when checking the payload generated after applying your migration. On this case
the validation keys are scoped only by the entity on which the ocurred: {entity}.{validation name}
Whenever a required property is missing in the definition, such as, for example, name
for fields of content types.
Example:
const author = migration.createContentType('author')
Whenever hitting the 50 fields limit on a content type, while trying to create a new field.
Example:
const author = migration.createContentType('author')
.name('Author')
for (let i = 0; i < 60; i++) {
author.createField('dummy-' + i)
.name('Dummy field ' + i)
.type('Symbol')
}
Whenever setting the displayField
of a content type to an ID of a field which doesn't exist.
Example:
const author = migration.createContentType('author')
.name('Author')
.displayField('fullName')
author.createField('firstName')
.name('First name')
.type('Symbol')
author.createField('lastName')
.name('Last name')
.type('Symbol')
Whenever trying to delete the field used as the displayField
of the content type.
Example:
const author = migration.createContentType('author')
.name('Author')
.displayField('fullName')
author.createField('fullName')
.name('Full name')
.type('Symbol')
author.deleteField('fullName')
When setting a new field ID to the value it already has.
Example:
author.changeFieldId('fullName', 'fullName')
When giving a field an ID that another field on the same content type already has.
Example:
author.createField('fullName')
.name('Full name')
.type('Symbol')
author.changeFieldId('firstName', 'fullName')
When setting a new field ID that does not match the requirements.
Example:
author.changeFieldId('fullName', '!%#')
Whenever a required property is missing in the definition, such as, for example, the type
property of a field.
Example:
contentType.createField('author').name('Author')
// .type('Symbol') is missing
## field.REQUIRED_DEPENDENT_PROPERTY
Whenever editing an element, but forgetting to set a required property, such as `items` for fields of type `Array` or `linkType` for fields of type `Link`.
**Example:**
```javascript
const author = migration.createContentType('author')
.name('Author')
author.createField('articles')
.name('Written articles')
.type('Array')
// Missing the `items` property
Whenever using a property which is not compatible with the type of the field.
Example:
const author = migration.createContentType('author')
.name('Author')
author.createField('fullName')
.name('Full name')
.type('Symbol')
.items({ type: 'Asset' })
// `items` is not compatible with field type `Symbol`.
Whenever trying to set a field type with a value which is not allowed.
Example:
author.createField('fullName')
.name('Full name')
.type('Wrong')
Allowed types are listed in the createField
documentation.
Whenever using deleted(true)
on a field which hasn't been omitted first (using omitted(true)
).
Example:
const author = migration.editContentType('author')
// Missing the following code:
// author.editField('fullName')
// .omitted(true)
author.editField('fullName')
.deleted(true)
Note: you may use the deleteField
shorthand method to do both operations at once.
Whenever trying to edit the type
of an existing field.
Example:
author.createField('fullName')
.name('Full name')
.type('Symbol')
author.editField('fullName').type('Text')
Field types can't be changed, you must disable and omit the field, and create a new field with the right type and a different ID instead.
Whenever trying to add the same validation twice.
Example:
author.createField('fullName')
.name('Full name')
.type('Symbol')
.validations([
{ unique: true },
{ unique: true }
])
Whenever trying to set a non existing validation.
Example:
author.createField('fullName')
.name('Full name')
.type('Symbol')
.validations([
{ customValidation: { crazy: 'stuff' } },
])
Whenever trying to set the wrong parameters for a validation.
Example:
author.createField('fullName')
.name('Full name')
.type('Symbol')
.validations([
{ unique: 'yes' }, // needs to be Boolean
{ size: 5 } // needs to be object { min, max }
])
When setting the same property on a content type or field multiple times.
Example:
author.createField('fullName')
.name('Full name')
.type('Symbol')
.name('Name')
Note that steps in the migration description are grouped into what will be requests to Contentful's API. If the property changes would not end up in the same request because they are done in a later, separate step, this will not produce an error.
Example:
author.createField('fullName')
.name('Full name')
.type('Symbol')
migration.deleteContentType('reader');
author.editField('fullName')
.name('Name')