{"id":22382401,"url":"https://github.com/jcoreio/react-final-form-graceful-field","last_synced_at":"2026-02-11T03:03:56.942Z","repository":{"id":78315552,"uuid":"296440994","full_name":"jcoreio/react-final-form-graceful-field","owner":"jcoreio","description":"parse and format that work how you actually want them to for react-final-form","archived":false,"fork":false,"pushed_at":"2024-01-25T13:21:23.000Z","size":1788,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-19T07:01:13.466Z","etag":null,"topics":["final-form","react-final-form"],"latest_commit_sha":null,"homepage":null,"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/jcoreio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2020-09-17T20:58:38.000Z","updated_at":"2022-07-12T17:07:34.000Z","dependencies_parsed_at":"2025-07-13T20:42:17.334Z","dependency_job_id":"0bf5602c-18eb-40cd-810d-6c3ced2ede49","html_url":"https://github.com/jcoreio/react-final-form-graceful-field","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/jcoreio/react-final-form-graceful-field","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Freact-final-form-graceful-field","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Freact-final-form-graceful-field/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Freact-final-form-graceful-field/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Freact-final-form-graceful-field/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcoreio","download_url":"https://codeload.github.com/jcoreio/react-final-form-graceful-field/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcoreio%2Freact-final-form-graceful-field/sbom","scorecard":{"id":511719,"data":{"date":"2025-08-11","repo":{"name":"github.com/jcoreio/react-final-form-graceful-field","commit":"67a8e6836922283db184fa6dc668945bc84a567d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"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":"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":"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":"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":"Code-Review","score":0,"reason":"Found 1/29 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":"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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md: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"}},{"name":"Vulnerabilities","score":0,"reason":"40 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-rmvr-2pp2-xj38","Warn: Project is vulnerable to: GHSA-xx4v-prfh-6cgc","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw","Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-434g-2637-qmqr","Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m","Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw","Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p","Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747","Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22","Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq","Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488","Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-5rrq-pxf6-6jx5","Warn: Project is vulnerable to: GHSA-8fr3-hfg3-gpgp","Warn: Project is vulnerable to: GHSA-gf8q-jrpm-jvxq","Warn: Project is vulnerable to: GHSA-2r2c-g63r-vccr","Warn: Project is vulnerable to: GHSA-cfm4-qjh2-4765","Warn: Project is vulnerable to: GHSA-x4jg-mjrx-434g","Warn: Project is vulnerable to: GHSA-76c9-3jph-rj3q","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w","Warn: Project is vulnerable to: GHSA-h7cp-r72f-jxh6","Warn: Project is vulnerable to: GHSA-v62p-rq8g-8h59","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T00:42:54.529Z","repository_id":78315552,"created_at":"2025-08-20T00:42:54.529Z","updated_at":"2025-08-20T00:42:54.529Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29326078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T02:08:56.257Z","status":"ssl_error","status_checked_at":"2026-02-11T02:08:51.338Z","response_time":97,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["final-form","react-final-form"],"created_at":"2024-12-05T00:12:53.278Z","updated_at":"2026-02-11T03:03:56.937Z","avatar_url":"https://github.com/jcoreio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-final-form-graceful-field\n\n[![CircleCI](https://circleci.com/gh/jcoreio/react-final-form-graceful-field.svg?style=svg)](https://circleci.com/gh/jcoreio/react-final-form-graceful-field)\n[![Coverage Status](https://codecov.io/gh/jcoreio/react-final-form-graceful-field/branch/master/graph/badge.svg)](https://codecov.io/gh/jcoreio/react-final-form-graceful-field)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![npm version](https://badge.fury.io/js/react-final-form-graceful-field.svg)](https://badge.fury.io/js/react-final-form-graceful-field)\n\nparse and format that work how you actually want them to for `react-final-form`\n\n# Why you would want to use this\n\nIf you've wanted to take number typed in and store the value as an actual `number` instead of text, without destroying UX, this is for you.\nThat's what I wrote this for, although it supports any use case where you want to stash the raw value in field metadata.\n\nThe official advice from Erik Rasmussen is to store the raw string that was typed in and parse it in the submit handler, but that sucks:\n\n- Reparsing nested numeric fields within complex forms is a hassle\n- If you have validators that compare two numeric fields, for example a min \u003c= max constraint, you have to reparse the numbers there too.\n\n`react-final-form-graceful-field` allows you to use `parse` and `format` but it displays the raw value instead of formatted while\nthe field is active or `parse` threw an error. That's right, `parse` can throw an error, and doing so will trigger a validation error on the field as well.\n\nThis way you can successfully type in `5.23`, whereas a naive `parse={parseFloat}` approach will kill the `.` before you can type anything\nafter it.\n\n# Try it out!\n\nDemo CodeSandbox: https://codesandbox.io/s/react-final-form-graceful-field-example-n1onw?file=/src/index.js\n\n# Important\n\n**Important**: `react-final-form-graceful-field` requires you to use the [`setFieldData` mutator](https://github.com/final-form/final-form-set-field-data) on your form:\n\n```js\nimport setFieldData from 'final-form-set-field-data'\nconst mutators = { setFieldData }\n\nconst MyForm = () =\u003e (\n  \u003cForm mutators={mutators} onSubmit={console.log}\u003e\n    ...\n  \u003c/Form\u003e\n)\n```\n\n# Example\n\n```js\n// @flow\n\nimport * as React from 'react'\nimport { render } from 'react-dom'\nimport { Form } from 'react-final-form'\nimport { GracefulField } from '../src'\nimport setFieldData from 'final-form-set-field-data'\n\nconst format = (value: ?number): string =\u003e\n  Number.isFinite(value) ? String(value) : ''\n\nconst parse = (value: ?string): ?number =\u003e {\n  value = value ? value.trim() : null\n  if (!value) return null\n  const parsed = Number(value)\n  if (!Number.isFinite(parsed)) throw new Error(`invalid number`)\n  return parsed\n}\n\nconst mutators = { setFieldData }\n\nrender(\n  \u003cForm onSubmit={console.log} mutators={mutators}\u003e\n    {({ values, form, ...rest }) =\u003e (\n      \u003cdiv\u003e\n        \u003cGracefulField\n          name=\"price\"\n          format={format}\n          parse={parse}\n          component=\"input\"\n          invalidValue={NaN}\n        /\u003e\n        \u003cbutton type=\"button\" onClick={() =\u003e form.change('price', 5)}\u003e\n          Set to 5\n        \u003c/button\u003e\n        \u003cpre\u003e{JSON.stringify({ values, rest }, null, 2)}\u003c/pre\u003e\n      \u003c/div\u003e\n    )}\n  \u003c/Form\u003e,\n  (document.getElementById('root'): any)\n)\n```\n\n# API\n\n## `GracefulField`\n\n```js\nimport { GracefulField } from 'react-final-form-graceful-field'\n```\n\nHas the same API as `\u003cField\u003e` except:\n\n- `parse` may throw an error, which will trigger a validation error.\n- Accepts an `invalidValue` property, which will be used if `parse` throws an error.\n- No `formatOnBlur` property. It formats on blur by default if `parse` didn't throw an error and you provide `format`.\n\n## `useGracefulField`\n\n```js\nimport { useGracefulField } from 'react-final-form-graceful-field'\n```\n\nHas the same API as `useField` except:\n\n- `parse` may throw an error, which will trigger a validation error.\n- Accepts an `invalidValue` property, which will be used if `parse` throws an error.\n- No `formatOnBlur` property. It formats on blur by default if `parse` didn't throw an error and you provide `format`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcoreio%2Freact-final-form-graceful-field","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcoreio%2Freact-final-form-graceful-field","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcoreio%2Freact-final-form-graceful-field/lists"}