{"id":13517189,"url":"https://github.com/lukeed/formee","last_synced_at":"2025-10-09T18:24:01.103Z","repository":{"id":57240499,"uuid":"163493723","full_name":"lukeed/formee","owner":"lukeed","description":"A tiny (532B) library for handling \u003cform\u003e elements.","archived":false,"fork":false,"pushed_at":"2019-01-17T22:55:29.000Z","size":52,"stargazers_count":440,"open_issues_count":2,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-09-15T13:45:28.070Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://codepen.io/lukeed/pen/dwKWVa","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lukeed.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}},"created_at":"2018-12-29T08:40:34.000Z","updated_at":"2025-07-15T19:30:31.000Z","dependencies_parsed_at":"2022-08-30T00:11:46.188Z","dependency_job_id":null,"html_url":"https://github.com/lukeed/formee","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/lukeed/formee","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fformee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fformee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fformee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fformee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukeed","download_url":"https://codeload.github.com/lukeed/formee/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fformee/sbom","scorecard":{"id":604465,"data":{"date":"2025-08-11","repo":{"name":"github.com/lukeed/formee","commit":"7d764c84f364e71beac0237dfd54e45d8ebd9598"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 2/27 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: license:0","Info: FSF or OSI recognized license: MIT License: license:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T01:15:39.838Z","repository_id":57240499,"created_at":"2025-08-21T01:15:39.839Z","updated_at":"2025-08-21T01:15:39.839Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001940,"owners_count":26083226,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"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":"2024-08-01T05:01:30.862Z","updated_at":"2025-10-09T18:24:01.073Z","avatar_url":"https://github.com/lukeed.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"logo.png\" alt=\"formee\" height=\"120\" /\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://npmjs.org/package/formee\"\u003e\n    \u003cimg src=\"https://badgen.now.sh/npm/v/formee\" alt=\"version\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://travis-ci.org/lukeed/formee\"\u003e\n    \u003cimg src=\"https://badgen.now.sh/travis/lukeed/formee\" alt=\"travis\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://npmjs.org/package/formee\"\u003e\n    \u003cimg src=\"https://badgen.now.sh/npm/dm/formee\" alt=\"downloads\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://bundlephobia.com/result?p=formee\"\u003e\n    \u003cimg src=\"https://badgen.net/badgesize/brotli/https://unpkg.com/formee?label=brotli\" alt=\"install size\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003eA tiny (532B) library for handling \u0026#60;form\u0026#62; elements\u003c/div\u003e\n\n## Features\n\n* Includes `serialize` and `validation` methods\n* Compatible with any UI library\n* Fully [tree-shakeable](https://developer.mozilla.org/en-US/docs/Glossary/Tree_shaking)\n\nAdditionally, this module is delivered as:\n\n* **ES Module**: [`dist/formee.mjs`](https://unpkg.com/formee/dist/formee.mjs)\n* **CommonJS**: [`dist/formee.js`](https://unpkg.com/formee/dist/formee.js)\n* **UMD**: [`dist/formee.min.js`](https://unpkg.com/formee)\n\n\n## Install\n\n```\n$ npm install --save formee\n```\n\n\n## Usage\n\n\u003e :wave: [_View a full demo on CodePen_](https://codepen.io/lukeed/pen/dwKWVa)\n\n```html\n\u003cform id=\"foo\"\u003e\n  \u003ch2\u003eRegister\u003c/h2\u003e\n  \u003cinput type=\"email\" name=\"email\" /\u003e\n  \u003cinput type=\"password\" name=\"password\" /\u003e\n  \u003cinput type=\"password\" name=\"confirm\" /\u003e\n  \u003cbutton\u003eRegister\u003c/button\u003e\n\u003c/form\u003e\n```\n\n```js\nconst { validate } = require('formee');\n\nconst myForm = document.querySelector('#foo');\nconst myRules = {\n  // RegExp rule\n  email: /.+\\@.+\\..+/,\n  // Function, with custom error messages\n  password(val) {\n    if (!val) return 'Required';\n    return val.length \u003e= 8 || 'Must be at least 8 characters';\n  },\n  // Function, comparing to other value\n  confirm(val, data) {\n    if (!val) return 'Required';\n    return val === data.password || 'Must match your password';\n  }\n};\n\nmyForm.onsubmit = function (ev) {\n  ev.preventDefault();\n  let errors = validate(myForm, myRules);\n  if (myForm.isValid) return alert('Success!');\n  for (let k in errors) {\n    // TODO: Render errors manually\n    //   with {insert favorite UI lib here}\n    console.log(`My rule \u0026 element's name: ${k}`);\n    console.log('\u003e Error message:', errors[k] || 'Required');\n    console.log('\u003e My form element(s):', myForm.elements[k]);\n  }\n};\n```\n\n\n## API\n\n### formee.serialize(form)\nReturn: `Object`\n\nSerializes a `\u003cform\u003e` into a data object.\n\n\u003e **Important:** Any inputs that are unnamed, disabled, or are of `type=file|reset|submit|button` will be ignored.\n\n#### form\nType: `HTMLFormElement`\n\nThe `\u003cform\u003e` element to evaluate.\n\n\n### formee.validate(form, rules, toCheck)\nReturn: `Object`\n\nValidates a `\u003cform\u003e` according to its `rules`.\u003cbr\u003e\nTo check an individual input, you may pass its name as the `toCheck` value.\n\n\u003e **Important:** The `rules` key names must match `form.elements`' names~!\n\nReturns an Object of errors, whose keys are the failing `rules` keys (and the `name=\"\"`s of failing elements) and whose values are your error messages (if provided) else `false`.\n\nAdditionally, the `\u003cform\u003e` and _each of its elements_ will receive a new `isValid` property with a `Boolean` value.\u003cbr\u003eFor example:\n\n```js\nlet myForm = document.querySelector('#myform');\nlet errors = formee.validate(myForm, { ... });\n\nif (!myForm.isValid) {\n  let i=0, item;\n  for (; i \u003c myForm.elements; i++) {\n    item = myForm.elements[i];\n    console.log(`${item.name} – Am I valid?`, item.isValid);\n    item.isValid || console.log('\u003e\u003e my error message:', errors[item.name]);\n  }\n}\n```\n\n\n#### form\nType: `HTMLFormElement`\n\nThe `\u003cform\u003e` element to validate.\n\n#### rules\nType: `Object`\n\nAn object of rules for your form's inputs.\n\n\u003e **Important:** The key names must match a `\u003cform\u003e` element's `name=\"\"` attribute!\n\nThe form values will be serialized before reaching your rule(s). (see [`serialize`](#formeeserializeform))\u003cbr\u003e\nFor example, a `select[multiple]` may present its value as `undefined`, a String, or an Array of Strings.\n\nEach rule:\n\n* May be a `RegExp` or a `Function`\n* Must return `false` or an error message (`String`) if invalid\n* Otherwise, must return `true` if valid\n\nYour `Function`-type rules will receive the corresponding input's value _and_ the entire data object.\n\n```js\nvalidate(form, {\n  password(val, data) {\n    if (!val) return 'Required';\n    if (val.length \u003c 8) return 'Must be at least 8 characters';\n    if (val !== data.confirmPassword) return 'Please confirm your password!';\n    return true; // all good homie\n  }\n});\n```\n\n#### toCheck\nType: `String`\u003cbr\u003e\nDefault: `undefined`\n\nIf set, ***only*** the corresponding form element (with `name={toCheck}`) will be validated.\u003cbr\u003e\nWhen unset (default), all form elements will be validated.\n\n\u003e **Important:** The value must match a key within `rules` and a `name=\"\"` attribute for one of `\u003cform\u003e`'s elements.\n\n\n### formee.bind(form, options)\nReturn: `HTMLFormElement`\n\nAttaches [`serialize`](#formeeserializeform) and [`validate`](#formeevalidateform-rules-tocheck) methods to the `\u003cform\u003e` element.\n\nAlso registers a custom `onsubmit` handler that will:\n\n1) `event.preventDefault` the `\"submit\"` event\n2) Perform [`validate`](#formeevalidateform-rules-tocheck), then\n  a) If all validation passed, call your `options.onSubmit` function\n  b) Otherwise, call your `options.onError` function\n\n```js\nlet myForm = document.querySelector('#myform');\n\nformee.bind(myForm, {\n  rules: {\n    // ...\n  },\n  onSubmit(ev) {\n    // validation passed!\n    console.log(ev.errors); //=\u003e {}\n    console.log(ev.target === myForm); //=\u003e true\n    console.log(myForm.isValid, myForm.errors); //=\u003e true {}\n  },\n  onError(ev) {\n    // validation failed!\n    console.log(ev.errors); //=\u003e { ... }\n    console.log(ev.target === myForm); //=\u003e true\n    console.log(myForm.isValid, myForm.errors); //=\u003e false { ... }\n  }\n});\n\n// Now available:\n// ---\nform.serialize();\nform.validate(/* specific item? */);\n```\n\n#### form\nType: `HTMLFormElement`\n\nThe `\u003cform\u003e` element to evaluate.\n\n\n#### options.rules\nType: `Object`\n\nPassed directly to `validate` – see [`rules`](#rules).\n\n#### options.onSubmit\nType: `Function`\u003cbr\u003e\nRequired: `true`\n\nThe callback to run when validation succeeds fails.\n\nIt receives the original `event` – however, a `event.errors` property is added, containing the output from [`validate`](#formeevalidateform-rules-tocheck).\n\n#### options.onError\nType: `Function`\u003cbr\u003e\nRequired: `true`\n\nThe callback to run when validation fails.\n\nIt receives the original `event` – however, a `event.errors` property is added, containing the output from [`validate`](#formeevalidateform-rules-tocheck).\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fformee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukeed%2Fformee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fformee/lists"}