diff --git a/src/fields/validations.ts b/src/fields/validations.ts index f61d36f140..b1913b98ae 100644 --- a/src/fields/validations.ts +++ b/src/fields/validations.ts @@ -252,7 +252,7 @@ export const relationship: Validate = async return defaultMessage; } - if (!canUseDOM && typeof value !== 'undefined') { + if (!canUseDOM && typeof value !== 'undefined' && value !== null) { const values = Array.isArray(value) ? value : [value]; const invalidRelationships = values.filter((val) => { diff --git a/test/relationships/int.spec.ts b/test/relationships/int.spec.ts index 8757050f87..7eadd63a83 100644 --- a/test/relationships/int.spec.ts +++ b/test/relationships/int.spec.ts @@ -184,6 +184,18 @@ describe('Relationships', () => { customIdNumberRelation: 'bad-input', })).rejects.toThrow('The following field is invalid: customIdNumberRelation'); }); + + it('should allow update removing a relationship', async () => { + const result = await client.update({ + slug, + id: post.id, + data: { + relationField: null, + }, + }); + + expect(result.status).toEqual(200); + }); }); describe('depth', () => {