Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(api): publish the minimum length of a contact first name
Yudhi Armyndharis2770d73a2d16
diff --git a/src/modules/contact/dto/upsert-contact.dto.spec.ts b/src/modules/contact/dto/upsert-contact.dto.spec.tsnew file mode 100644index 000000000..1f37b8796--- /dev/null+++ b/src/modules/contact/dto/upsert-contact.dto.spec.ts@@ -0,0 +1,15 @@+import { ADDRESSBOOK_NAME_MAX_LENGTH, UpsertContactDto } from './upsert-contact.dto';++const property = (name: string) =>+ Reflect.getMetadata('swagger/apiModelProperties', UpsertContactDto.prototype, name) as {+ minLength?: number;+ maxLength?: number;+ };++// The validator refuses an empty first name; the contract has to publish the same bound, or a+// generated client accepts input the server then refuses.+describe('UpsertContactDto contract', () => {+ it('publishes the firstName length bounds the validator enforces', () => {+ expect(property('firstName')).toMatchObject({ minLength: 1, maxLength: ADDRESSBOOK_NAME_MAX_LENGTH });+ });+});diff --git a/src/modules/contact/dto/upsert-contact.dto.ts b/src/modules/contact/dto/upsert-contact.dto.tsindex f27342df0..180d34f0d 100644--- a/src/modules/contact/dto/upsert-contact.dto.ts+++ b/src/modules/contact/dto/upsert-contact.dto.ts@@ -5,7 +5,7 @@ import { IsOptional, IsString, MaxLength, MinLength } from 'class-validator';export const ADDRESSBOOK_NAME_MAX_LENGTH = 100;export class UpsertContactDto {- @ApiProperty({ description: "The contact's first name.", maxLength: ADDRESSBOOK_NAME_MAX_LENGTH })+ @ApiProperty({ description: "The contact's first name.", minLength: 1, maxLength: ADDRESSBOOK_NAME_MAX_LENGTH })@IsString()@MinLength(1)@MaxLength(ADDRESSBOOK_NAME_MAX_LENGTH)