From 50f23f67b37cedf9b54410029195cac82a510686 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Sat, 2 Aug 2025 11:15:21 +0300 Subject: [PATCH] feat: update customer and service schemas to enforce maxLength and required attributes - Added maxLength constraints to 'name' and 'phone' attributes in customer and service schemas. - Marked 'name' as required in both schemas. - Updated TypeScript definitions to reflect these changes. --- .../customer/content-types/customer/schema.json | 14 ++++++++------ .../service/content-types/service/schema.json | 4 +++- types/generated/contentTypes.d.ts | 17 ++++++++++++++--- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/api/customer/content-types/customer/schema.json b/src/api/customer/content-types/customer/schema.json index a0b2823..ad63d3a 100644 --- a/src/api/customer/content-types/customer/schema.json +++ b/src/api/customer/content-types/customer/schema.json @@ -14,6 +14,7 @@ "attributes": { "name": { "type": "string", + "maxLength": 100, "required": true }, "telegramId": { @@ -22,21 +23,22 @@ }, "phone": { "type": "string", - "unique": true, - "required": true + "maxLength": 20, + "required": true, + "unique": true }, "role": { "type": "enumeration", + "required": true, "enum": [ "client", "master" - ], - "required": true + ] }, "active": { "type": "boolean", - "default": false, - "required": false + "required": false, + "default": false }, "clients": { "type": "relation", diff --git a/src/api/service/content-types/service/schema.json b/src/api/service/content-types/service/schema.json index 2ae1c0a..594a3f1 100644 --- a/src/api/service/content-types/service/schema.json +++ b/src/api/service/content-types/service/schema.json @@ -13,7 +13,9 @@ "pluginOptions": {}, "attributes": { "name": { - "type": "string" + "type": "string", + "maxLength": 100, + "required": true }, "orders": { "type": "relation", diff --git a/types/generated/contentTypes.d.ts b/types/generated/contentTypes.d.ts index 8750649..f74f8ce 100644 --- a/types/generated/contentTypes.d.ts +++ b/types/generated/contentTypes.d.ts @@ -435,11 +435,18 @@ export interface ApiCustomerCustomer extends Struct.CollectionTypeSchema { > & Schema.Attribute.Private; masters: Schema.Attribute.Relation<'manyToMany', 'api::customer.customer'>; - name: Schema.Attribute.String & Schema.Attribute.Required; + name: Schema.Attribute.String & + Schema.Attribute.Required & + Schema.Attribute.SetMinMaxLength<{ + maxLength: 100; + }>; orders: Schema.Attribute.Relation<'oneToMany', 'api::order.order'>; phone: Schema.Attribute.String & Schema.Attribute.Required & - Schema.Attribute.Unique; + Schema.Attribute.Unique & + Schema.Attribute.SetMinMaxLength<{ + maxLength: 20; + }>; photoUrl: Schema.Attribute.String; publishedAt: Schema.Attribute.DateTime; role: Schema.Attribute.Enumeration<['client', 'master']> & @@ -522,7 +529,11 @@ export interface ApiServiceService extends Struct.CollectionTypeSchema { > & Schema.Attribute.Private; master: Schema.Attribute.Relation<'manyToOne', 'api::customer.customer'>; - name: Schema.Attribute.String; + name: Schema.Attribute.String & + Schema.Attribute.Required & + Schema.Attribute.SetMinMaxLength<{ + maxLength: 100; + }>; orders: Schema.Attribute.Relation<'manyToMany', 'api::order.order'>; publishedAt: Schema.Attribute.DateTime; updatedAt: Schema.Attribute.DateTime;