{"id":50580110,"url":"https://github.com/codewithmark/one-line-validator","last_synced_at":"2026-06-05T01:02:42.124Z","repository":{"id":299006366,"uuid":"1001805961","full_name":"codewithmark/one-line-validator","owner":"codewithmark","description":"Validate Any Form in 60 Seconds (1 Line of Code!)","archived":false,"fork":false,"pushed_at":"2025-08-20T22:30:50.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-21T00:25:16.361Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codewithmark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-14T04:21:16.000Z","updated_at":"2025-08-20T22:30:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"874a7fed-592a-49f1-b08b-3912f7d48c68","html_url":"https://github.com/codewithmark/one-line-validator","commit_stats":null,"previous_names":["codewithmark/one-line-validator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codewithmark/one-line-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmark%2Fone-line-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmark%2Fone-line-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmark%2Fone-line-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmark%2Fone-line-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codewithmark","download_url":"https://codeload.github.com/codewithmark/one-line-validator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewithmark%2Fone-line-validator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33926275,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-04T02:00:06.755Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-05T01:02:37.211Z","updated_at":"2026-06-05T01:02:42.117Z","avatar_url":"https://github.com/codewithmark.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🧪 OneLineValidator\n\n**A lightweight, beginner-friendly JavaScript class for validating HTML forms with custom error messages and clean visual feedback.**\n\n---\n\n## 🚀 Features\n\n* ✅ One-line validation with `OneLineValidator.validate(...)`\n* 🎯 Custom error messages via `id` or `class`\n* 🔄 Live field validation on input/change\n* ✨ Styled error messages with animation\n* 📦 Returns form data object when valid, `false` when not\n* 💡 Treats any field with a custom error as required (no `required` attribute needed)\n\n---\n\n## 🛠️ Installation\n\nDownload or copy `OneLineValidator.js` into your project.\n\nThen include it:\n\n```html\n\u003cscript src=\"OneLineValidator.js\"\u003e\u003c/script\u003e\n```\n\nOr import via module (if using bundlers like Vite/Webpack):\n\n```js\nimport OneLineValidator from './OneLineValidator.js';\n```\n\n---\n\n## ✅ Usage Example\n\n### HTML Form\n\n```html\nIMPORTANT NOTE \u003e all the input fields need to have id assigned to it otherwise return object will be null\n\n\u003cform id=\"myForm\"\u003e\n  \u003cinput type=\"email\" id=\"email\" /\u003e\n  \u003cinput type=\"password\" class=\"password\" id=\"password\" /\u003e\n  \u003cinput type=\"password\" id=\"confirmPassword\" /\u003e\n  \u003cinput type=\"tel\" class=\"phone\"  id=\"phone\" /\u003e\n  \u003cinput type=\"checkbox\" id=\"terms\" /\u003e\n  \u003cbutton type=\"submit\"\u003eSubmit\u003c/button\u003e\n\u003c/form\u003e\n```\n\n### JavaScript\n\n```js\n\n//IMPORTANT NOTE \u003e all the input fields need to have id assigned to it otherwise return object will be null\nconst customErrors = [\n  { id: \"email\", msg: \"Please enter a valid email address.\" },\n  { class: \"password\", msg: \"Password must be at least 6 characters.\" },\n  { id: \"confirmPassword\", msg: \"Passwords must match.\" },\n  { class: \"phone\", msg: \"Enter a valid phone number (10–15 digits).\" },\n  { id: \"terms\", msg: \"You must accept the terms to continue.\" }\n];\n\ndocument.querySelector('#myForm').addEventListener('submit', function (e) {\n  e.preventDefault();\n\n  const data = OneLineValidator.validate('#myForm', customErrors);\n\n  if (data) {\n    console.log('✅ Form is valid!', data);\n    // Submit or use data\n  } else {\n    console.log('❌ Form has errors');\n  }\n});\n```\n\n---\n\n## 📦 Return Format (If Valid)\n\n```json\n{\n  \"email\": \"user@example.com\",\n  \"password\": \"abc123\",\n  \"confirmPassword\": \"abc123\",\n  \"phone\": \"+1234567890\",\n  \"terms\": true\n}\n```\n\n---\n\n## 🎨 Styling\n\nStyles are automatically injected:\n\n* `.field-error` adds a red border and light red background\n* `.error-message` shows an animated message with an ❌ icon\n\n---\n\n## 📚 License\n\nMIT — free to use, modify, and share.\n\n---\n\n## 💬 Author\n\nBuilt by \\[Code With Mark].\nContributions, suggestions, and issues welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodewithmark%2Fone-line-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodewithmark%2Fone-line-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodewithmark%2Fone-line-validator/lists"}