{"id":27976965,"url":"https://github.com/lemoncode/fonk-negative-number-validator","last_synced_at":"2025-05-08T01:43:34.057Z","repository":{"id":74273647,"uuid":"207832449","full_name":"Lemoncode/fonk-negative-number-validator","owner":"Lemoncode","description":"Negative number validator for https://github.com/Lemoncode/fonk","archived":false,"fork":false,"pushed_at":"2019-11-07T09:07:15.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-08T01:43:28.446Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/Lemoncode.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}},"created_at":"2019-09-11T14:28:08.000Z","updated_at":"2019-11-07T09:07:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"645ee224-f7a8-4f7f-b8e3-c859379354c7","html_url":"https://github.com/Lemoncode/fonk-negative-number-validator","commit_stats":{"total_commits":16,"total_committers":2,"mean_commits":8.0,"dds":0.25,"last_synced_commit":"6f6e8dd6006df9525afa0080edbd05045ce9a071"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lemoncode%2Ffonk-negative-number-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lemoncode%2Ffonk-negative-number-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lemoncode%2Ffonk-negative-number-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lemoncode%2Ffonk-negative-number-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lemoncode","download_url":"https://codeload.github.com/Lemoncode/fonk-negative-number-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252983759,"owners_count":21835758,"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","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":"2025-05-08T01:43:33.392Z","updated_at":"2025-05-08T01:43:33.977Z","avatar_url":"https://github.com/Lemoncode.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fonk-negative-number-validator\n\n[![CircleCI](https://badgen.net/github/status/Lemoncode/fonk-negative-number-validator/master?icon=circleci\u0026label=circleci)](https://circleci.com/gh/Lemoncode/fonk-negative-number-validator/tree/master)\n[![NPM Version](https://badgen.net/npm/v/@lemoncode/fonk-negative-number-validator?icon=npm\u0026label=npm)](https://www.npmjs.com/package/@lemoncode/fonk-negative-number-validator)\n[![bundle-size](https://badgen.net/bundlephobia/min/@lemoncode/fonk-negative-number-validator)](https://bundlephobia.com/result?p=@lemoncode/fonk-negative-number-validator)\n\nThis is a [fonk](https://github.com/Lemoncode/fonk) microlibrary that brings validation capabilities to:\n\n- Validate if a field of a form is a negative number\n\nHow to install it:\n\n```bash\nnpm install @lemoncode/fonk-negative-number-validator --save\n```\n\nHow to add it to an existing form validation schema:\n\nWe have the following form model:\n\n```\nconst myFormValues = {\n  product: 'shoes',\n  price: 20,\n}\n```\n\nWe can add a negativeNumber validation to the myFormValues\n\n```javascript\nimport { negativeNumber } from '@lemoncode/fonk-negative-number-validator';\n\nconst validationSchema = {\n  field: {\n    price: [negativeNumber.validator],\n  },\n};\n```\n\nThe validator must be configured with the following required arguments:\n\n```javascript\nexport interface CustomValidatorArgs {\n  strictTypes?: boolean;\n  allowZero?: boolean;\n}\n```\n\nThese are the default arguments:\n\n```javascript\nlet defaultCustomArgs: CustomValidatorArgs = {\n  strictTypes: false,\n  allowZero: false,\n};\n```\n\nYou can specify the custom arguments in two ways:\n\n- Locally just customize the arguments for this validationSchema (e.g. We can specify if the validator allows zero):\n\n```javascript\nimport { negativeNumber } from '@lemoncode/fonk-negative-number-validator';\n\nconst validationSchema = {\n  field: {\n    price: [\n      {\n        validator: negativeNumber.validator,\n        customArgs: { allowZero: true },\n      },\n    ],\n  },\n};\n```\n\n- Globally, replace the default custom arguments in all validationSchemas (e.g. enable strict types):\n\n```javascript\nimport { negativeNumber } from '@lemoncode/fonk-negative-number-validator';\n\nnegativeNumber.setCustomArgs({ strictTypes: true });\n```\n\nYou can customize the error message displayed in two ways:\n\n- Globally, replace the default error message in all validationSchemas (e.g. porting to spanish):\n\n```javascript\nimport { negativeNumber } from '@lemoncode/fonk-negative-number-validator';\n\nnegativeNumber.setErrorMessage('El campo debe de ser un número negativo');\n```\n\n- Locally just override the error message for this validationSchema:\n\n```javascript\nimport { negativeNumber } from '@lemoncode/fonk-negative-number-validator';\n\nconst validationSchema = {\n  field: {\n    price: [\n      {\n        validator: negativeNumber.validator,\n        message: 'Error message only updated for the validation schema',\n      },\n    ],\n  },\n};\n```\n\nPlease, refer to [fonk](https://github.com/Lemoncode/fonk) to know more.\n\n## License\n\n[MIT](./LICENSE)\n\n# About Basefactor + Lemoncode\n\nWe are an innovating team of Javascript experts, passionate about turning your ideas into robust products.\n\n[Basefactor, consultancy by Lemoncode](http://www.basefactor.com) provides consultancy and coaching services.\n\n[Lemoncode](http://lemoncode.net/services/en/#en-home) provides training services.\n\nFor the LATAM/Spanish audience we are running an Online Front End Master degree, more info: http://lemoncode.net/master-frontend\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemoncode%2Ffonk-negative-number-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemoncode%2Ffonk-negative-number-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemoncode%2Ffonk-negative-number-validator/lists"}