From 74e05633497d061d901901ae3b38b3b951afc7b7 Mon Sep 17 00:00:00 2001 From: "Carlos (Almeira)" Date: Mon, 22 Jun 2026 14:33:06 -0500 Subject: [PATCH] fix(forms): enforce string field length limits globally --- src/app/actions/entities.ts | 29 +++++++++++++++++++ src/components/dashboard/EntityForm.tsx | 10 ++++++- .../publications/PublicationLayout.tsx | 2 ++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/app/actions/entities.ts b/src/app/actions/entities.ts index d4f2797..80d4734 100644 --- a/src/app/actions/entities.ts +++ b/src/app/actions/entities.ts @@ -28,6 +28,8 @@ function extractCleanData(entity: string, formData: FormData): Record f.type === 'number').map(f => f.name)); const booleanKeys = new Set(fields.filter(f => f.type === 'boolean').map(f => f.name)); + const textKeys = new Set(fields.filter(f => f.type === 'text' || f.type === 'url' || f.type === 'select').map(f => f.name)); + const data: Record = {}; for (const [key, value] of formData.entries()) { @@ -54,6 +56,12 @@ function extractCleanData(entity: string, formData: FormData): Record setTitle(e.target.value)} placeholder={`Nombre de ${field.label}...`} + maxLength={250} className="w-full bg-transparent border-b-2 border-slate-800 py-2 text-2xl font-bold text-white focus:outline-none focus:border-cyan-500 transition-all placeholder:text-slate-700" /> ) : field.type === 'textarea' ? ( @@ -288,7 +289,14 @@ export const EntityForm = ({ ) : ( - + )} ); diff --git a/src/components/publications/PublicationLayout.tsx b/src/components/publications/PublicationLayout.tsx index b8a4cf7..dbc9fa2 100644 --- a/src/components/publications/PublicationLayout.tsx +++ b/src/components/publications/PublicationLayout.tsx @@ -240,6 +240,7 @@ export const PublicationLayout: React.FC = ({ onChange={(e) => setTitulo(e.target.value)} placeholder="Escribe un título llamativo..." required + maxLength={250} className={inputClass} /> @@ -259,6 +260,7 @@ export const PublicationLayout: React.FC = ({ onChange={(e) => { setSlug(e.target.value); setIsAutoSlug(false); }} placeholder="url-de-la-publicacion" required + maxLength={100} className={`${inputClass} font-mono`} />