{"id":21063530,"url":"https://github.com/bosnaufal/argvalid","last_synced_at":"2026-02-17T19:01:49.000Z","repository":{"id":57145688,"uuid":"81178037","full_name":"BosNaufal/argvalid","owner":"BosNaufal","description":"Make Sure That Your Variable Is Valid. It's Inspired By https://vuejs.org/v2/guide/components.html#Props","archived":false,"fork":false,"pushed_at":"2017-02-08T03:22:20.000Z","size":8,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T14:42:09.784Z","etag":null,"topics":["checker","checker-service","props","validation","validations","validator","validators","variable"],"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/BosNaufal.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}},"created_at":"2017-02-07T07:10:45.000Z","updated_at":"2017-03-01T13:36:31.000Z","dependencies_parsed_at":"2022-09-06T00:22:13.127Z","dependency_job_id":null,"html_url":"https://github.com/BosNaufal/argvalid","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BosNaufal%2Fargvalid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BosNaufal%2Fargvalid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BosNaufal%2Fargvalid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BosNaufal%2Fargvalid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BosNaufal","download_url":"https://codeload.github.com/BosNaufal/argvalid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254455949,"owners_count":22074067,"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":["checker","checker-service","props","validation","validations","validator","validators","variable"],"created_at":"2024-11-19T17:45:49.395Z","updated_at":"2025-10-03T13:34:33.877Z","avatar_url":"https://github.com/BosNaufal.png","language":"JavaScript","readme":"# Argvalid\n\nMake Sure That Your Variable Is Valid. It's usefull for runtime debugging. It will cut off your process whenever it found an unvalid variable. It's inspired by [Vue Props Validation](https://vuejs.org/v2/guide/components.html#Props) and it works simliarly.\n\n## Installation\nYou can import [argvalid.js](./dist/argvalid.js) to your project files and process it with your preprocessor. **It Very recommended to use ES2015**. Because it will make you **easy to write** since [argvalid.js](https://github.com/BosNaufal/argvalid) is using [Property Shorthand](http://es6-features.org/#PropertyShorthand) Of ES6/ES2015\n\nYou can install it via NPM\n```bash\nnpm install argvalid\n```\n\n## Usage\n```javascript\nimport argvalid from 'argvalid';\n\n// Simple Example    \nlet obj = {\n\n  // Simple Validation\n  test(name) {\n    const valid = argvalid({ name }, { // You Probably should note the first argument writing style\n        type: String, // Is Using instanceof as a default validator\n        required: true // Is it required to fill?\n      }\n    )\n  },\n\n  // Default Value\n  defaultValue(hello) {\n    const valid = argvalid({ hello }, {\n        type: Number,\n        defaultValue: 1 // You can set the default value of it\n      }\n    )\n  },\n\n  // Default Value With Function\n  defaultValueFunc(hello) {\n    const valid = argvalid({ hello }, {\n        type: Number,\n        defaultValue: () =\u003e 1\n      }\n    )\n  },\n\n  // You can validate many variable at once\n  // And It will not change your writing style. Just put it in the array\n  inArray(id, name) {\n    const valid = argvalid([\n      { id }, {\n        type: Number,\n        required: true\n      },\n\n      { name }, {\n        type: String,\n        required: true,\n        defaultValue: \"\"\n      },\n    ])\n  },\n\n  // You can use 2 or more types at once\n  arrayTypes(datas) {\n    const valid = argvalid({ datas },{\n      type: [Boolean, Array], // Put it in an array\n      required: true,\n      defaultValue: false\n    })\n  },\n\n  // You can even use custom validator\n  customValidator(custom) {\n    const valid = argvalid({ custom },{\n      required: true,\n      // Just put it\n      validator(val) {\n        if (val.length === 3) return true\n        return false\n      }\n    })\n  }\n\n  // After valid, you can use it as an object or just use it.\n  itReturnObject(a, i, u, e, o) {\n    const valid = argvalid([\n      { a }, {\n        type: Number,\n        required: true\n      },\n\n      { i }, {\n        type: String,\n        required: true,\n        defaultValue: \"\"\n      },\n\n      { u }, {\n        type: Object,\n      },\n\n      { e }, {\n        type: Array,\n        required: true,\n        defaultValue: \"\"\n      },\n\n      { o }, {\n        type: Date,\n        required: true,\n      },\n\n    ])\n\n    console.log(typeof valid === 'object'); // true\n  }\n\n}\n\n\n// Then Run Some Function\nobj.test() // Will Throw Error\n\n```\n\n## Thank You for Making this useful~\n\n## Let's talk about some projects with me\nJust Contact Me At:\n- Email: [bosnaufalemail@gmail.com](mailto:bosnaufalemail@gmail.com)\n- Skype Id: bosnaufal254\n- twitter: [@BosNaufal](https://twitter.com/BosNaufal)\n\n\n## License\n[MIT](http://opensource.org/licenses/MIT)\nCopyright (c) Naufal Rabbani\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbosnaufal%2Fargvalid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbosnaufal%2Fargvalid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbosnaufal%2Fargvalid/lists"}