Docs/DTOs
Combining Decorators
Decorators stack — use them together for full validation + documentation. Each of @validateProperty, @transformProperty and @documentProperty is applied once per property, and @fileUploadProperty stands alone (it defines a file, they define a field): a repeat would replace the first one's setting, so it throws AladoConfigurationError with code: 'DECORATOR_REPEATED' at startup (3.9.8). Combine several checks in one validator, for example validate.string().email().required().build().
The validator gives the schema (here { type: 'string', format: 'uuid' }, required), @documentProperty the description and example; see @documentProperty.
TypeScript
export class Id {
@validateProperty({
handler: validate.string().uuid().required().build(),
error: {
statusCode: 400,
message: 'Invalid UUID',
},
})
@documentProperty({
example: '7ef5ed25-53b1-432f-96ec-8e35d830eb9c',
description: 'Resource identifier',
})
id: string = '7ef5ed25-53b1-432f-96ec-8e35d830eb9c';
}