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.
17 lines (14 loc) • 424 B
JavaScript
const typo = require("typo-js");
const dictionary = new typo("en_US");
module.exports = {
correct: (input, fieldType) => {
const words = input.split(" ");
const correctedWords = words.map(word => {
if (!dictionary.check(word)) {
return dictionary.suggest(word)[0] || word;
}
return word;
});
return correctedWords.join(" ");
}
};