fix(backend): prohibit posting whitespace-only notes

This commit is contained in:
zyoshoka 2024-01-11 22:50:21 +09:00
parent b92c9726bd
commit d83c01af6c
No known key found for this signature in database
GPG key ID: 0C2CB8FBA309A5B8
2 changed files with 7 additions and 0 deletions

View file

@ -48,6 +48,11 @@ describe('api:notes/create', () => {
expect(v({ text: await tooLong })) expect(v({ text: await tooLong }))
.toBe(INVALID); .toBe(INVALID);
}); });
test('whitespace-only post', () => {
expect(v({ text: ' ' }))
.toBe(INVALID);
});
}); });
describe('cw', () => { describe('cw', () => {

View file

@ -138,6 +138,7 @@ export const paramDef = {
minLength: 1, minLength: 1,
maxLength: MAX_NOTE_TEXT_LENGTH, maxLength: MAX_NOTE_TEXT_LENGTH,
nullable: true, nullable: true,
pattern: '[^\\s]+',
}, },
fileIds: { fileIds: {
type: 'array', type: 'array',
@ -195,6 +196,7 @@ export const paramDef = {
minLength: 1, minLength: 1,
maxLength: MAX_NOTE_TEXT_LENGTH, maxLength: MAX_NOTE_TEXT_LENGTH,
nullable: false, nullable: false,
pattern: '[^\\s]+',
}, },
}, },
required: ['text'], required: ['text'],