# formZed Utility Function

The `formZed` function provides predefined field configurations for commonly used form inputs, such as name, email, phone number, and password. It helps maintain consistency in form validation and input attributes.

## 📌 Features

• Returns input field configurations, including `placeholder`, `type`, `maxLength`, and `minLength`.  
• Standardizes form input attributes for common fields.  
• Supports various input types, such as `text`, `email`, `password`, and `tel`.  
• Automatically generates a title by formatting the field name.  
• Ensures validation constraints are met.

## 🚀 Installation

To use this utility in your project, you can install it via `pnpm`, `npm`, or `yarn` if packaged as a module.

1. Install the utility:

```bash
pnpm add @estarlincito/utils
# or
npm install @estarlincito/utils
# or
yarn add @estarlincito/utils
```

2. Import the function in your project:

```ts
import { formZed } from '@estarlincito/utils';
```

## ⚡ Usage

The `formZed` function simplifies the process of configuring form fields with predefined values.

### Example 1: Get Configuration for an Email Input

```ts
const emailField = formZed('email');
console.log(emailField);
/* 
{
  placeholder: 'name@domain.com',
  type: 'email',
  maxLength: 30,
  minLength: 5,
  title: 'Email'
}
*/
```

### Example 2: Get Configuration for a Password Input

```ts
const passwordField = formZed('password');
console.log(passwordField);
/* 
{
  placeholder: '4ppl3-1Ph0ne',
  type: 'password',
  maxLength: 30,
  minLength: 8,
  title: 'Password'
}
*/
```

## ❌ Incorrect Usage

```ts
const field = formZed('address'); // ❌ Returns undefined as 'address' is not defined in formZed
```

## ✅ Correct Usage

```ts
const field = formZed('username'); // ✅ Returns configuration for 'username'
```

## 🛠 How It Works

• Accepts a field name and looks up its predefined configuration.  
• If the field is found, it returns an object containing its attributes.  
• The field title is automatically generated by capitalizing the first letter and replacing hyphens with spaces.  
• If the field is not found, it logs an error using `handleError` and returns `undefined`.

## ⚠️ Error Handling

If an invalid field name is provided, `formZed` calls `handleError` and logs an error message:

```ts
handleError(`${name} was not found in (fiels) /lib/zed.ts`);
```

This ensures better debugging and prevents unexpected behavior.

## 📝 License

This project is licensed under the MIT License - see the [LICENSE](../LICENSE) file for details.

**Author:** Estarlin R ([estarlincito.com](https://estarlincito.com))
