diff --git a/packages/backend/src/server/api/endpoints/notes/create.test.ts b/packages/backend/src/server/api/endpoints/notes/create.test.ts index 0aa05a2c93..3228bbd014 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.test.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.test.ts @@ -48,6 +48,11 @@ describe('api:notes/create', () => { expect(v({ text: await tooLong })) .toBe(INVALID); }); + + test('whitespace-only post', () => { + expect(v({ text: ' ' })) + .toBe(INVALID); + }); }); describe('cw', () => { diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index 52a32b7fec..ed522e03c9 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -138,6 +138,7 @@ export const paramDef = { minLength: 1, maxLength: MAX_NOTE_TEXT_LENGTH, nullable: true, + pattern: '[^\\s]+', }, fileIds: { type: 'array', @@ -195,6 +196,7 @@ export const paramDef = { minLength: 1, maxLength: MAX_NOTE_TEXT_LENGTH, nullable: false, + pattern: '[^\\s]+', }, }, required: ['text'],