{"id":28823566,"url":"https://github.com/gcsboss/valinor","last_synced_at":"2025-10-24T10:59:37.260Z","repository":{"id":184264432,"uuid":"202778922","full_name":"GCSBOSS/valinor","owner":"GCSBOSS","description":"A NodeJS library for writing uncluttered, easy to read field and schema validations.","archived":false,"fork":false,"pushed_at":"2021-03-23T15:13:27.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-05-08T23:00:47.852Z","etag":null,"topics":["api","assert","complete","custom","field","library","nodejs","required","schema","test","validation"],"latest_commit_sha":null,"homepage":"","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/GCSBOSS.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2019-08-16T18:23:03.000Z","updated_at":"2021-03-23T15:12:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"c84cafe9-8614-43e9-8564-94cc3c18521b","html_url":"https://github.com/GCSBOSS/valinor","commit_stats":null,"previous_names":["gcsboss/valinor"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/GCSBOSS/valinor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GCSBOSS%2Fvalinor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GCSBOSS%2Fvalinor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GCSBOSS%2Fvalinor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GCSBOSS%2Fvalinor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GCSBOSS","download_url":"https://codeload.github.com/GCSBOSS/valinor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GCSBOSS%2Fvalinor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260654700,"owners_count":23042680,"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":["api","assert","complete","custom","field","library","nodejs","required","schema","test","validation"],"created_at":"2025-06-19T00:10:10.748Z","updated_at":"2025-10-24T10:59:37.255Z","avatar_url":"https://github.com/GCSBOSS.png","language":"JavaScript","readme":"# [Valinor](https://gitlab.com/GCSBOSS/valinor)\n\nA library for writing uncluttered, easy to read field and schema validations.\n\n## Get Started\n\nInstall with: `npm i -P valinor`\n\nIn your code:\n\n```js\nconst v = require('valinor');\n\n// Validate one variable in place.\nlet result = v.int.between(0, 32).test(33);\nconsole.log(result);\n\n// Reuse one valinor.\nlet goodPwd = v.str.min(8);\nconsole.log(\n    goodPwd.test('abc'),\n    goodPwd.test('abcdefgh'),\n    goodPwd.test(null)\n);\n\n// Define a object schema valinor.\nlet schema = v.schema({\n    name: v.str.match(/^[A-Z][a-z]+\\ [A-Z][a-z]+$/),\n    password: v.str.min(8),\n    birth: v.date.min('2001-01-01').past\n});\n\nresult = schema.test({\n    name: 'John Doe',\n    password: 'abcdefgh',\n    birth: new Date('1999-01-01')\n});\n\n// Remove an object's properties that are not present in the schema.\nlet coolData = schema.clip(\"{\\\"totally\\\":\\\"invalid\\\"}\");\n\n// Ignore empty/null values on optional valinors.\nlet schemaWithOpt = v.schema({\n    firstName: v.str,\n    lastName: v.opt.str\n});\n\nconsole.log(schemaWithOpt.test({\n    firstName: 'John',\n    lastName: null\n}));\n\n// Ensure you get only valdated keys of an object.\nconsole.log(schemaWithOpt.test({\n    firstName: 'John',\n    unvalidated: 'This should not show up',\n    lastName: 'Doe'\n}).final);\n\n// Define default values to show up in final object instead of blank optionals\nlet schemaWithOpt = v.schema({\n    firstName: v.str,\n    lastName: v.opt.str.def('Doe')\n});\n\nconsole.log(schemaWithOpt.test({\n    firstName: 'John'\n}).final);\n\n```\n\n`v.test()` method output is always an object with the following keys:\n\n- `ok`: Whether validation passed.\n- `errs`: Array containing all found validation errors. Empty array if all passed.\n\nCheck the [full rule reference](#rule-reference) for all the validations available.\n\n## Reporting Bugs\nIf you have found any problems with this module, please:\n\n1. [Open an issue](https://gitlab.com/GCSBOSS/valinor/issues/new).\n2. Describe what happened and how.\n3. Also in the issue text, reference the label `~bug`.\n\nWe will make sure to take a look when time allows us.\n\n## Proposing Features\nIf you wish to get that awesome feature or have some advice for us, please:\n1. [Open an issue](https://gitlab.com/GCSBOSS/valinor/issues/new).\n2. Describe your ideas.\n3. Also in the issue text, reference the label `~proposal`.\n\n## Contributing\nIf you have spotted any enhancements to be made and is willing to get your hands\ndirty about it, fork us and\n[submit your merge request](https://gitlab.com/GCSBOSS/valinor/merge_requests/new)\nso we can collaborate effectively.\n\n## Method Reference\n\n- `test ( input )`: Returns true if the input is valid. Returns an array or problems otherwise.\n\n## Rule Reference\n\n- `in ( array )`: Check if value can be found inside given array.\n- `num`: Check if value is a number.\n- `bool`: Check if value is a boolean.\n- `date`: Check if value is a date.\n- `obj`: Check if value is an object. Will fail for arrays, dates and JSON strings.\n- `str`: Check if value is a string.\n- `func`: Check if value is a function. Will fail for BoundFunctions and AsyncFunctions.\n- `arr`: Check if value is array. Will fail for JSON strings.\n- `match ( regex )`: Check if value matches the given regex.\n- `eq ( primitive | date | array )`: Check if values are sctrictly equal. In Arrays, consider also order of elements.\n- `gt ( primitive | date | array )`: Check if value or it's length is greater than subject.\n- `lt ( primitive | date | array )`: Check if value or it's length is less than subject.\n- `min ( primitive | date | array )`: Check if value or it's length is equal or greater than the subject.\n- `max ( primitive | date | array )`: Check if value or it's length is equal or less than the subject.\n- `between ( primitive | date | array )`: Check if value or it's length is inclusively inside the given range.\n- `len ( string | array )`: Check if length is exactly the given subject.\n- `has ( string | object | array )`: Check if the value contains the subject. For string, object and array it checks respectively substring, keys and values.\n- `future ( date )`: Check if a date is in the future.\n- `past ( date )`: Check if a date is in the past.\n- `today ( date )`: Check if a date time is today.\n- `schema ( object )`: Check if object's keys follows all their respective Valinor rules.\n- `every ( array )`: Check if all array elements match a given Valinor rules.\n- `some ( array )`: Check if any values of the array match given rules. Also picks only the valid values.\n- `opt`: Mark the Valinor as optional, so skipping any validations for null, undefined or '' values.\n- `notIn ( array )`: Check if value cannot be found inside given array.\n- `notNum`, `notBool`, `notDate`, `notObj`, `notStr`, `notFunc`, `notArr`: Reverse type checkers. Read counterparts above for more info.\n- `notMatch ( regex )`: Check if value does not matche the given regex.\n- `dif ( primitive | date | array )`: Check if values are sctrictly different. In Arrays, consider also order of elements.\n- `notBetween ( primitive | date | array )`: Check if value or it's length is exclusively not inside the given range.\n- `notLen ( string | array )`: Check if length is different than the given subject.\n- `hasnt ( string | object | array )`: Check if the value does not contain the subject. For string, object and array it checks respectively substring, keys and values.\n- `notFuture ( date )`: Check if a date is NOT in the future.\n- `notPast ( date )`: Check if a date is NOT in the past.\n- `notToday ( date )`: Check if a date time is NOT today.\n- `def ( value )`: Set a default value to show up on `final` object in case the valinor is optional and validates an empty value.\n- `alter ( fn )`: Mutates the input value acording to given funcion (`fn`) in a pipeline fashion before it reaches the next rule.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgcsboss%2Fvalinor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgcsboss%2Fvalinor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgcsboss%2Fvalinor/lists"}