form-genius
Version:
š AI-powered, dynamic, and customizable form validation for Node.js. Supports unlimited fields, auto-detection, real-time validation, and AI-based corrections.
178 lines (134 loc) ⢠6.1 kB
Markdown
# **Form-Genius š**
**AI-Powered Dynamic Form Validator for Node.js**




**Form-Genius** is an **AI-powered, highly customizable, and dynamic form validation** package for Node.js. It supports unlimited fields, real-time validation, AI-based auto-corrections, and customizable validation rules. Whether you're working on a simple contact form or a complex application requiring secure validation, **Form-Genius** is the perfect solution.
---
## š **Why Use Form-Genius?**
ā
**Unlimited Fields** ā Validate **any** number of fields dynamically.
ā
**AI-Powered Corrections** ā Suggests fixes for typos, formatting issues, and invalid inputs.
ā
**Auto Field-Type Detection** ā Automatically detects input type (email, phone, password, etc.).
ā
**Custom Rules Support** ā Define **your own validation rules** for full flexibility.
ā
**Real-Time Validation** ā Easily integrates with front-end frameworks like React, Vue, and Angular.
ā
**Multi-Language Support** ā Works with various languages and regional formats.
ā
**Security & Fraud Detection** ā AI-based algorithms prevent fake/spam submissions.
ā
**Lightweight & Fast** ā Designed for high-performance applications.
---
## š **Installation**
```sh
npm install form-genius
```
---
## š ļø **How It Works**
1. Define your **form fields**.
2. Set up **validation rules** for each field.
3. Use `form-genius` to validate **all inputs dynamically**.
4. Get **real-time feedback** with errors and AI-generated suggestions.
---
## š **Usage Example**
### **Basic Example**
```javascript
const validateForm = require("form-genius");
const userData = {
email: "john.doe@gmal.com",
phone: "+123 456 7890",
password: "pass",
website: "htt://invalid-url.com",
age: "17",
username: "john_doe_123",
address: "1600 Amphitheatre Pkwy, California"
};
const validationRules = {
password: { minLength: 8 },
website: { type: "url" }, // User-defined type override
age: { type: "number", min: 18, max: 99 },
address: { type: "address" }, // AI-powered address validation
username: { type: "username", minLength: 3, maxLength: 15 }
};
console.log(validateForm(userData, validationRules));
```
### **Output Example**
```json
{
"valid": false,
"errors": {
"password": "Password must be at least 8 characters",
"website": "Invalid URL format",
"age": "Must be at least 18"
},
"suggestions": {
"email": "john.doe@gmail.com",
"website": "http://invalid-url.com"
}
}
```
---
## šÆ **Supported Validations**
š¹ **Basic Validations**
- Required fields
- Min/max length
- Allowed characters
š¹ **Data Type-Specific Validations**
- **Email** ā Validate format, suggest correct domain (`gmal.com` ā `gmail.com`)
- **Phone Number** ā Auto-format numbers, detect invalid inputs
- **Password** ā Strength validation (uppercase, numbers, special characters)
- **Username** ā No spaces, supports underscores, min/max length
- **URL** ā Ensures valid website addresses
- **Date** ā Ensures correct date formats (`MM-DD-YYYY`, `YYYY-MM-DD`)
- **Number** ā Range validation (`min`, `max`)
- **Address** ā Uses Google Maps API for real-world validation
š¹ **Advanced AI-Based Features**
- **Contextual Text Correction** ā AI fixes common typos
- **Fraud Detection** ā Detects fake/spam submissions
- **Real-Time Validation** ā Perfect for frontend form validation
---
## š¦ **Integrating with Express.js (API Example)**
Easily validate user input in your Express.js application.
```javascript
const express = require("express");
const validateForm = require("form-genius");
const app = express();
app.use(express.json());
app.post("/register", (req, res) => {
const validationRules = {
email: { type: "email" },
password: { minLength: 8 },
username: { type: "username", minLength: 3, maxLength: 15 }
};
const result = validateForm(req.body, validationRules);
if (!result.valid) return res.status(400).json(result);
res.json({ success: true, message: "User registered successfully!" });
});
app.listen(3000, () => console.log("Server running on port 3000"));
```
---
## š **Use Cases**
ā
**E-commerce Websites** ā Validate shipping addresses, phone numbers, and payment details.
ā
**User Registration Forms** ā Secure authentication with strong passwords and valid emails.
ā
**Finance & Banking Apps** ā Validate account details securely.
ā
**Healthcare Applications** ā Ensure medical forms are properly filled.
ā
**Job Portals & Applications** ā Validate structured resume submissions.
---
## āļø **Versioning**
Current Stable Version: **`1.0.0`**
- š **New Features**: AI-powered validation, customizable rules, auto-detection
- š„ **Performance**: Optimized for high-speed validation
---
## š„ **Contributing**
We welcome contributions! Feel free to submit issues and pull requests.
### **To Contribute:**
1. Fork the repository
2. Create a new feature branch
3. Make changes and commit
4. Submit a pull request
---
## š **Support My Work**
If you love **Form-Genius**, consider buying me a coffee! ā
[](https://www.buymeacoffee.com/imankii01)
---
## š **License**
This project is licensed under the **MIT License**. See the full **[LICENSE](./LICENSE)** file for details.
---
š **Form-Genius** makes form validation smarter, faster, and more powerful. Install it today and take your **form validation to the next level!** š”# form-genius