UNPKG

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.

19 lines (15 loc) • 429 B
const typo = require("typo-js"); const dictionary = new typo("en_US"); module.exports = function validateText(text) { const words = text.split(" "); const correctedWords = words.map(word => { if (!dictionary.check(word)) { return dictionary.suggest(word)[0] || word; } return word; }); return { valid: true, correctedText: correctedWords.join(" ") }; };