From 44a016256717b871ada858d5dc064d9d0e06425e Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Thu, 18 May 2023 22:04:52 -0600 Subject: Añade creación de direcciones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/form_utils.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/lib/form_utils.ts') diff --git a/src/lib/form_utils.ts b/src/lib/form_utils.ts index af29463..43fe0fa 100644 --- a/src/lib/form_utils.ts +++ b/src/lib/form_utils.ts @@ -1,8 +1,8 @@ +import FieldProperties from "../components/forms/fields/field_properties"; import Token from "./token"; -export interface Error { - field_div_id: string; - field_input_id: string; +export interface FormError { + field_name: string; message: string; } @@ -23,6 +23,17 @@ export function setFormErrorsInSessionStorage(errors: Array) { } } +export function setFieldErrorMessages(fields: FieldProperties[], errors: FormError[]) { + for(const field of fields) { + const error = errors.find(e => e.field_name == field.name) + if(error){ + field.error_message = error.message; + } + } + + return fields; +} + export function clearSessionStorage() { const token = new Token(); const stored_token = sessionStorage.getItem('token'); -- cgit v1.2.3