{"id":20252405,"url":"https://github.com/ivandotv/validar-decorators","last_synced_at":"2025-08-01T23:08:43.609Z","repository":{"id":39060313,"uuid":"208427952","full_name":"ivandotv/validar-decorators","owner":"ivandotv","description":"Decorators for the validar package. https://github.com/ivandotv/validar","archived":false,"fork":false,"pushed_at":"2025-07-29T21:50:23.000Z","size":608,"stargazers_count":2,"open_issues_count":19,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-30T00:01:25.983Z","etag":null,"topics":["object-schema","typescript","validation"],"latest_commit_sha":null,"homepage":"","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/ivandotv.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,"zenodo":null}},"created_at":"2019-09-14T11:02:47.000Z","updated_at":"2025-07-28T15:47:04.000Z","dependencies_parsed_at":"2024-06-29T08:37:55.504Z","dependency_job_id":"5aec78ec-8dc9-43ef-a165-87a800041810","html_url":"https://github.com/ivandotv/validar-decorators","commit_stats":{"total_commits":99,"total_committers":4,"mean_commits":24.75,"dds":"0.46464646464646464","last_synced_commit":"d6acbe3ef0596570d115a5eab4ccf097f84dd956"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/ivandotv/validar-decorators","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fvalidar-decorators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fvalidar-decorators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fvalidar-decorators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fvalidar-decorators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivandotv","download_url":"https://codeload.github.com/ivandotv/validar-decorators/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivandotv%2Fvalidar-decorators/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268310795,"owners_count":24230185,"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-08-01T02:00:08.611Z","response_time":67,"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":["object-schema","typescript","validation"],"created_at":"2024-11-14T10:16:32.921Z","updated_at":"2025-08-01T23:08:43.569Z","avatar_url":"https://github.com/ivandotv.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Validar Decorators\n\n[![CircleCI](https://img.shields.io/circleci/build/github/ivandotv/validar-decorators/master)](https://circleci.com/gh/ivandotv/validar-decorators)\n[![Codecov](https://img.shields.io/codecov/c/github/ivandotv/validar-decorators)](https://codecov.io/gh/ivandotv/validar-decorators)\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/validar-decorators)\n[![NPM](https://img.shields.io/npm/l/validar-decorators)](https://www.npmjs.com/package/validar-decorators)\n\nDecorators for the [validar package](https://github.com/ivandotv/validar).\n\n## Install\n\n```js\nnpm install validar-decorators\n```\n\nAs decorators are a part of future [ECMAScript standard](https://github.com/tc39/proposals) they can only be used with transpilers such as [Babel](http://babeljs.io/) or [Typescript](https://www.typescriptlang.org/).\n\nThis package is written in typescript.\n\n## Example\n\n```js\n// person.ts\nimport { isValid, validateClass, validateClassAsync } from 'validar-decorators'\nimport { validation } from 'validar'\n\nclass Person {\n  // @isValid decorator accepts validation\n  @isValid(validation(() =\u003e true))\n  public name: string\n\n  // or array of validations\n  @isValid([validation(() =\u003e true),validation(() =\u003e true)])\n  public lastName: string\n\n  @isValid({\n    address: {\n      street: validation(() =\u003e true),\n      appartmentNumber: validation(() =\u003e true),\n    },\n    city: validation(() =\u003e true),\n    country: validation(() =\u003e false),\n  })\n  public location: Location\n}\n```\n\n```js\n// application.ts\nconst person = new Person()\n\nperson.name = 'Sam'\nperson.lastName = 'Fisher'\nperson.location = {\n  address: {\n    street: 'Beverly Hills',\n    appartmentNumber: 33,\n    city: 'LA',\n    country: 'USA',\n  },\n}\n\n// actual validation step\nconst result = validateClass(person)\n\n// if you have async tests\nvalidateClassAsync(person).then(result =\u003e {\n  console.log(result)\n})\n```\n\n### Static properties\n\nYou can also validate static properties.\n\n```js\nclass Person {\n  static totalCount: number = 3000\n  static males: number = 1500\n  static females: number = 1500\n}\n\nconst result = validateClass(Person)\n\n// if you have async tests\nvalidateClassAsync(person).then(result =\u003e {\n  console.log(result)\n})\n```\n\n### Working with subclasses\n\nSubclasses inherit validation checks from the parent class, but they can also override them.\n\n```js\nclass Person {\n  @isValid(validation(() =\u003e true))\n  name: string = 'Sam'\n\n  @isValid(validation(() =\u003e true))\n  lastName: string\n}\n\nclass Pilot extends Person {\n  // override validation\n  @isValid(validation(() =\u003e false))\n  name: string\n\n  // override validation\n  @isValid(validation(() =\u003e false))\n  lastName: string\n\n  @isValid(validation(() =\u003e false))\n  nick: string\n}\n\nconst pilot = new Pilot()\npilot.name = 'Pete'\npilot.lastName = 'Mitchell'\npilot.nick = 'Maveric'\n\n// actual validation step\nconst result = validateClass(pilot)\n```\n\nFor more info about [`validar`](https://ivandotv.github.io/validar/) package check out the [documentation](https://ivandotv.github.io/validar/)\n\n### API docs\n\n`Validar Decorators` is written in TypeScript, [auto generated API docs](https://github.com/ivandotv/validar-decorators/blob/master/docs/api/README.md) are available.\n\n##### Author\n\n- **Ivan Vlatković**\n\n##### License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivandotv%2Fvalidar-decorators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivandotv%2Fvalidar-decorators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivandotv%2Fvalidar-decorators/lists"}