{"id":22096494,"url":"https://github.com/uphold/validator.js-asserts","last_synced_at":"2025-10-27T11:16:05.005Z","repository":{"id":23060298,"uuid":"26413671","full_name":"uphold/validator.js-asserts","owner":"uphold","description":"A set of extra asserts for validator.js.","archived":false,"fork":false,"pushed_at":"2025-07-15T10:06:35.000Z","size":901,"stargazers_count":8,"open_issues_count":13,"forks_count":4,"subscribers_count":57,"default_branch":"master","last_synced_at":"2025-07-15T21:55:24.832Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://uphold.github.io/validator.js-asserts","language":"JavaScript","has_issues":false,"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/uphold.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-11-09T23:52:37.000Z","updated_at":"2025-07-01T14:00:02.000Z","dependencies_parsed_at":"2024-06-18T21:15:13.751Z","dependency_job_id":"d9310276-e28d-4027-81c5-e8e5d7b88d50","html_url":"https://github.com/uphold/validator.js-asserts","commit_stats":{"total_commits":131,"total_committers":28,"mean_commits":4.678571428571429,"dds":0.8244274809160306,"last_synced_commit":"b37a5d977f9688538afe0e60707c8ae1f6e7bd07"},"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"purl":"pkg:github/uphold/validator.js-asserts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uphold%2Fvalidator.js-asserts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uphold%2Fvalidator.js-asserts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uphold%2Fvalidator.js-asserts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uphold%2Fvalidator.js-asserts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uphold","download_url":"https://codeload.github.com/uphold/validator.js-asserts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uphold%2Fvalidator.js-asserts/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266913680,"owners_count":24005579,"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-07-24T02:00:09.469Z","response_time":99,"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-12-01T04:11:14.828Z","updated_at":"2025-10-27T11:15:59.974Z","avatar_url":"https://github.com/uphold.png","language":"JavaScript","readme":"# validator.js-asserts\n\nA set of extra asserts for [validator.js](https://github.com/guillaumepotier/validator.js).\n\n## Status\n\n[![npm version][npm-image]][npm-url]\n[![build status][ci-image]][ci-url]\n\n## Installation\n\nInstall the package via `npm`:\n\n```sh\nnpm install --save validator.js-asserts\n```\n\n### Peer dependencies\n\nSome asserts require manually installing some _peer dependencies_. Failing to do so will result in runtime errors, as packages are required dynamically.\n\nPeer dependencies are listed on `package.json` under `peerDependencies`.\nThe `peerDependenciesMeta` key identifies which peer dependencies are optional. NPM will not automatically install optional peer dependencies. See [the NPM documentation](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#peerdependenciesmeta) for more information.\n\n## Asserts\n\nThe following set of extra asserts are provided by this package:\n\n| Assert                                                                          | Peer Dependency                                      |\n| :------------------------------------------------------------------------------ | :--------------------------------------------------- |\n| [AbaRoutingNumber](#abaroutingnumber)                                           | [`abavalidator`][abavalidator-url]                   |\n| [BankIdentifierCode](#bankidentifiercode-bic) (_BIC_)                           |                                                      |\n| [BigNumber](#bignumber)                                                         | [`bignumber.js`][bignumber-url]                      |\n| [BigNumberEqualTo](#bignumberequalto)                                           | [`bignumber.js`][bignumber-url]                      |\n| [BigNumberGreaterThan](#bignumbergreaterthan)                                   | [`bignumber.js`][bignumber-url]                      |\n| [BigNumberGreaterThanOrEqualTo](#bignumbergreaterthanorequalto)                 | [`bignumber.js`][bignumber-url]                      |\n| [BigNumberLessThan](#bignumberlessthan)                                         | [`bignumber.js`][bignumber-url]                      |\n| [BigNumberLessThanOrEqualTo](#bignumberlessthanorequalto)                       | [`bignumber.js`][bignumber-url]                      |\n| [Boolean](#boolean)                                                             |                                                      |\n| [Callback](#callback)                                                           | [`callback`][callback-url]                           |\n| [CaZipCode](#cazipcode)                                                         |                                                      |\n| [CpfNumber](#cpfnumber)                                                         | [`cpf`][cpf-url]                                     |\n| [CreditCard](#creditcard)                                                       | [`creditcard`][creditcard-url]                       |\n| [CurpNumber](#curpnumber)                                                       | [`curp`][curp-url]                                   |\n| [Date](#date)                                                                   | [`moment`][moment-url]                               |\n| [DateDiffGreaterThan](#datediffgreaterthan)                                     | [`moment`][moment-url]                               |\n| [DateDiffGreaterThanOrEqualTo](#datediffgreaterthanorequalto)                   | [`moment`][moment-url]                               |\n| [DateDiffLessThan](#datedifflessthan)                                           | [`moment`][moment-url]                               |\n| [DateDiffLessThanOrEqualTo](#datedifflessthanorequalto)                         | [`moment`][moment-url]                               |\n| [Email](#email)                                                                 | [`validator`][validator-url]                         |\n| [EqualKeys](#equalkeys)                                                         |                                                      |\n| [Hash](#hash)                                                                   |                                                      |\n| [Integer](#integer)                                                             |                                                      |\n| [InternationalBankAccountNumber](#internationalbankaccountnumber-iban) (_IBAN_) | [`iban`][iban-url]                                   |\n| [Ip](#ip)                                                                       |                                                      |\n| [Iso3166Country](#iso3166country)                                               | [`isoc`][isoc-url]                                   |\n| [Json](#json)                                                                   |                                                      |\n| [NotEmpty](#notempty)                                                           |                                                      |\n| [NullOr](#nullor)                                                               |                                                      |\n| [NullOrDate](#nullordate)                                                       |                                                      |\n| [NullOrBoolean](#nullorboolean)                                                 |                                                      |\n| [NullOrString](#nullorstring)                                                   |                                                      |\n| [Phone](#phone)                                                                 | [`google-libphonenumber`][google-libphonenumber-url] |\n| [PlainObject](#plainobject)                                                     |                                                      |\n| [RfcNumber](#rfcnumber)                                                         | [`validate-rfc`][validate-rfc-url]                   |\n| [TaxpayerIdentificationNumber](#taxpayeridentificationnumber) (_TIN_)           | [`tin-validator`][tin-validator-url]                 |\n| [UkModulusChecking](#ukmoduluschecking)                                         | [`uk-modulus-checking`][uk-modulus-checking-url]     |\n| [Uri](#uri)                                                                     | [`urijs`][urijs-url]                                 |\n| [UsSubdivision](#ussubdivision)                                                 |                                                      |\n| [UsZipCode](#uszipcode)                                                         |                                                      |\n| [Uuid](#uuid)                                                                   |                                                      |\n\n### AbaRoutingNumber\n\nTests if the value is a valid [ABA Routing Number](http://www.accuity.com/PageFiles/255/ROUTING_NUMBER_POLICY.pdf).\n\n### BankIdentifierCode (_BIC_)\n\nTests if the value is a valid Bank Identifier Code (_BIC_) as defined in the [ISO-9362](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=60390) standard.\n\n### BigNumber\n\nTests if the value is a valid `BigNumber`.\n\n### BigNumberEqualTo\n\nTests if a `BigNumber` is equal to a given value.\n\n#### Arguments\n\n- `value` (required)\n\n### BigNumberGreaterThan\n\nTests if a `BigNumber` is greater than a given threshold.\n\n#### Arguments\n\n- `threshold` (required)\n\n### BigNumberGreaterThanOrEqualTo\n\nTests if a `BigNumber` is greater than or equal to a given threshold.\n\n#### Arguments\n\n- `threshold` (required)\n\n### BigNumberLessThan\n\nTests if a `BigNumber` is less than a given threshold.\n\n#### Arguments\n\n- `threshold` (required)\n\n### BigNumberLessThanOrEqualTo\n\nTests if a `BigNumber` is less than or equal to a given threshold.\n\n#### Arguments\n\n- `threshold` (required)\n\n### Boolean\n\nTests if the value is a boolean.\n\n### Callback\n\nAllows you to add custom rules by giving a callback function and a custom class.\n\n#### Arguments\n\n- `callback` (required) - the callback function.\n- `customClass` (required) - the name of the class.\n\n### CaZipCode\n\nTests if the value is a valid Canada zip code (postal code).\nWe only allow initial characters from the list on the [site](https://www.canadapost-postescanada.ca/cpc/en/support/articles/addressing-guidelines/postal-codes.page).\n\n### CpfNumber\n\nTests if the value is a valid Brazilian CPF (Cadastro de Pessoas Físicas) number.\n\n### CreditCard\n\nTests if the value is a valid credit card number using the Luhn10 algorithm.\n\n### CurpNumber\n\nTests if the value is a valid Mexican CURP (Clave Única de Registro de Población) number.\n\n### Date\n\nTests if the value is a valid date.\n\n#### Arguments\n\n- `format` (optional) - the format in which the date must be in.\n\n### DateDiffGreaterThan\n\nTests if the difference between two dates is greater than a given threshold.\n\n#### Arguments\n\n- `threshold` (required)\n- `options`\n  - `absolute` - whether the comparison should use the absolute value of the measured difference.\n  - `asFloat` - whether to return the difference rounded down or as float.\n  - `fromDate` - the date where the diff is measured with. If omitted, defaults to `now`.\n  - `unit` - the unit of the difference measurement (`years`, `months`, `weeks`, `days`, `hours`, `minutes` and `seconds`).\n\n### DateDiffGreaterThanOrEqualTo\n\nTests if the difference between two dates is greater than or equal to a given threshold.\n\n#### Arguments\n\n- `threshold` (required)\n- `options`\n  - `absolute` - whether the comparison should use the absolute value of the measured difference.\n  - `asFloat` - whether to return the difference rounded down or as float.\n  - `fromDate` - the date where the diff is measured with. If omitted, defaults to `now`.\n  - `unit` - the unit of the difference measurement (`years`, `months`, `weeks`, `days`, `hours`, `minutes` and `seconds`).\n\n### DateDiffLessThan\n\nTests if the difference between two dates is less than a given threshold.\n\n#### Arguments\n\n- `threshold` (required)\n- `options`\n  - `absolute` - whether the comparison should use the absolute value of the measured difference.\n  - `asFloat` - whether to return the difference rounded down or as float.\n  - `fromDate` - the date where the diff is measured with. If omitted, defaults to `now`.\n  - `unit` - the unit of the difference measurement (`years`, `months`, `weeks`, `days`, `hours`, `minutes` and `seconds`).\n\n### DateDiffLessThanOrEqualTo\n\nTests if the difference between two dates is less than or equal to a given threshold.\n\n#### Arguments\n\n- `threshold` (required)\n- `options`\n  - `absolute` - whether the comparison should use the absolute value of the measured difference.\n  - `asFloat` - whether to return the difference rounded down or as float.\n  - `fromDate` - the date where the diff is measured with. If omitted, defaults to `now`.\n  - `unit` - the unit of the difference measurement (`years`, `months`, `weeks`, `days`, `hours`, `minutes` and `seconds`).\n\n### Email\n\nTests if the value is a valid email.\n\n### EqualKeys\n\nTests if the object has the exact given set of keys (missing or extra keys are not allowed).\n\n#### Arguments\n\n- `keys` (optional) - the keys that the object being tested must equal. If none are defined, no keys will be allowed.\n\n### Hash\n\nTests if the value is a valid hash.\n\n#### Arguments\n\n- `algorithm` (required) - the algorithm to test the hash for. Supported algorithms are `sha1`, `sha256` and `sha512`.\n\n### Integer\n\nTests if the value is an integer.\n\n### InternationalBankAccountNumber (_IBAN_)\n\nTests if the value is a valid International Bank Account Number (_IBAN_) as defined in the [13616-1](http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=41031) standard.\n\n### Ip\n\nTests if the value is a valid `IP` (v4 or v6).\n\n### Iso3166Country\n\nTests if the value is a valid ISO-3166 country by alpha-3 code, alpha-2 code, short name or uppercase name. All officially-assigned, transitionally-assigned and user-assigned codes are considered valid.\n\n### Json\n\nTests if the value is valid `JSON`.\n\n### NotEmpty\n\nTests if the value is not an empty (empty object, empty array, empty string, etc).\n\n### NullOr\n\nTests if the value is a `null` or validates against the assert received as an argument.\n\n### NullOrBoolean\n\nTests if the value is a `null` or `boolean`.\n\n### NullOrString\n\nTests if the value is a `null` or `string`, optionally within some boundaries.\n\n#### Arguments\n\n- `boundaries` (optional) - `max` and/or `min` boundaries to test the string for.\n\n### Phone\n\nTests if the phone is valid and optionally if it belongs to the given country. The phone can be in the national or E164 formats.\n\n#### Arguments\n\n- `countryCode` (optional) - the ISO-3166 alpha-2 country code to test the phone validity in.\n\n### PlainObject\n\nTests if the value is a plain object.\n\n### RfcNumber\n\nTests if the value is a valid Mexican `RFC` (Registro Federal de Contribuyentes) number.\n\n### TaxpayerIdentificationNumber\n\nTests if the value is a valid Taxpayer Identification Number `TIN` as defined by the [U.S. IRS](http://www.irs.gov/Individuals/International-Taxpayers/Taxpayer-Identification-Numbers-TIN).\n\n### UkModulusChecking\n\nTests if the given `accountNumber` and `sortCode` represent a valid `Faster Payment Account`.\n\n### Uri\n\nTests if the value is a valid `URI` (Uniform Resource Identifier) which must contain at least a protocol and a hostname.\n\n#### Arguments\n\n- `constraints` (optional) - additional `URI` parts to test for (e.g. `{ is: 'domain', protocol: 'https' }`).\n\n### UsSubdivision\n\nTests if the value is a valid US subdivision or not. By default, codes in the short (\"alpha2\", e.g. `CA`) or full form (e.g. `US-CA`) are allowed. All US subdivisions categories are supported: `districts` (1), `states` (50) and `outlying` territories (6).\n\n#### Arguments\n\n- `alpha2Only` (optional) - whether to restrict validation to the \"alpha2\" short code form only.\n- `categories` (optional) - a list of categories to restrict code validation to (e.g. `['states', 'outlying']`).\n\n### UsZipCode\n\nTests if the value is a valid US zip code.\n\n### UUID\n\nTests if the value is a valid `UUID`.\n\n#### Arguments\n\n- `version` (optional) - the version to test the `UUID` for. Supported versions are `3`, `4`, `5`, `7`, `max`, and `nil`. Defaults to test for `all` if omitted.\n\n## Usage\n\nThe following is an example for the extra IP assert:\n\n```js\nconst Validator = require('validator.js').Validator;\nconst is = require('validator.js').Assert.extend(require('validator.js-asserts'));\nconst validator = new Validator();\n\n// Validate IP `1.3.3.7`.\nlet violation = validator.validate('1.3.3.7', is.ip());\n\nif (true === violation) {\n  console.log('\"1.3.3.7\" is a valid IP'); // =\u003e \"1.3.3.7\" is a valid IP\n}\n\n// Validate IP `foo`.\nviolation = validator.validate('foo', is.ip());\n\nif (true !== violation) {\n  console.log('\"foo\" is not a valid IP. Violation:', violation[0].show());\n  // =\u003e \"foo\" is not a valid IP. Violation: { assert: 'Ip', value: 'foo' }\n}\n\n// Make the validation nullable.\nviolation = validator.validate(null, is.nullOr(is.ip()));\n\nif (true === violation) {\n  console.log('null is null or a valid IP'); // =\u003e null is null or a valid IP\n}\n```\n\n## Tests\n\n```sh\nnpm test\n```\n\n## Release process\n\nThe release of a version is automated via the [release](https://github.com/uphold/validator.js-asserts/actions/workflows/release.yaml) GitHub workflow. Run it by clicking the \"Run workflow\" button.\n\n## License\n\nMIT\n\n[npm-image]: https://img.shields.io/npm/v/validator.js-asserts.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/validator.js-asserts\n[ci-image]: https://github.com/uphold/validator.js-asserts/actions/workflows/ci.yaml/badge.svg?branch=master\n[ci-url]: https://github.com/uphold/validator.js-asserts/actions/workflows/ci.yaml\n[abavalidator-url]: https://www.npmjs.com/package/abavalidator\n[bignumber-url]: https://www.npmjs.com/package/bignumber.js\n[callback-url]: https://www.npmjs.com/package/callback\n[cpf-url]: https://www.npmjs.com/package/cpf\n[creditcard-url]: https://www.npmjs.com/package/creditcard\n[curp-url]: https://www.npmjs.com/package/curp\n[google-libphonenumber-url]: https://www.npmjs.com/package/google-libphonenumber\n[iban-url]: https://www.npmjs.com/package/iban\n[isoc-url]: https://www.npmjs.com/package/isoc\n[moment-url]: https://www.npmjs.com/package/moment\n[tin-validator-url]: https://www.npmjs.com/package/tin-validator\n[uk-modulus-checking-url]: https://www.npmjs.com/package/uk-modulus-checking\n[urijs-url]: https://www.npmjs.com/package/urijs\n[validate-rfc-url]: https://www.npmjs.com/package/validate-rfc\n[validator-url]: https://www.npmjs.com/package/validator\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuphold%2Fvalidator.js-asserts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuphold%2Fvalidator.js-asserts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuphold%2Fvalidator.js-asserts/lists"}