{"id":19737951,"url":"https://github.com/devsu/condor-validate","last_synced_at":"2026-05-14T00:40:03.151Z","repository":{"id":57205264,"uuid":"93538679","full_name":"devsu/condor-validate","owner":"devsu","description":"Validate GRPC Requests and Metadata","archived":false,"fork":false,"pushed_at":"2017-06-07T15:29:49.000Z","size":9,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-08T23:27:58.748Z","etag":null,"topics":[],"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/devsu.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-06-06T16:15:07.000Z","updated_at":"2018-09-28T13:55:57.000Z","dependencies_parsed_at":"2022-09-18T01:22:17.787Z","dependency_job_id":null,"html_url":"https://github.com/devsu/condor-validate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devsu/condor-validate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsu%2Fcondor-validate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsu%2Fcondor-validate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsu%2Fcondor-validate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsu%2Fcondor-validate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devsu","download_url":"https://codeload.github.com/devsu/condor-validate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsu%2Fcondor-validate/sbom","scorecard":{"id":338444,"data":{"date":"2025-08-11","repo":{"name":"github.com/devsu/condor-validate","commit":"765c2179ab06cd9fa3ba3cbec1a19fe46468c5cb"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/4 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-18T05:15:14.208Z","repository_id":57205264,"created_at":"2025-08-18T05:15:14.208Z","updated_at":"2025-08-18T05:15:14.208Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285879574,"owners_count":27247109,"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-11-22T02:00:05.934Z","response_time":64,"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-11-12T01:12:52.374Z","updated_at":"2025-11-23T00:02:53.591Z","avatar_url":"https://github.com/devsu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# condor-validate\n\nValidation middleware for [Condor GRPC Server](https://github.com/devsu/condor-framework). It provide helpers to validate requests and metadata.\n\n[![Build Status](https://travis-ci.org/devsu/condor-validate.svg?branch=master)](https://travis-ci.org/devsu/condor-validate)\n[![Coverage Status](https://coveralls.io/repos/github/devsu/condor-validate/badge.svg)](https://coveralls.io/github/devsu/condor-validate)\n\n## Installation\n\n```bash\nnpm i --save condor-validate\nnpm i --save condor-framework\n```\n\n## Usage\n\n```js\nconst Condor = require('condor-framework');\nconst validate = require('condor-validate');\nconst Greeter = require('./greeter');\n\nconst server = new Condor()\n  .add('path/to/file.proto', 'GreeterService', new Greeter())\n  .use(validate())\n  .start();\n```\n\nAnd, then in your `Greeter` class:\n\n```js\nmodule.exports = class {\n  sayHello(ctx) {\n    // check the values of request\n    ctx.checkRequest('name').notEmpty('Name cannot be empty');\n    ctx.checkRequest('age').optional().isInt().gte(0, 'Age cannot be negative');\n    ctx.checkRequest('other.email').optional().isEmail('Invalid email');\n    \n    // checks the value of ctx.metadata.get('authorization')[0]\n    ctx.checkMetadata('authorization').notEmpty();\n    \n    // you can determine the index of metadata to check\n    ctx.checkMetadata('authorization', 1).notEmpty();\n    \n    // You can also check using jsonpath (view https://github.com/dchester/jsonpath)\n    ctx.checkRequest('$.store.book[*].author').first().notEmpty();\n    \n    // if any errors, finalizes the call\n    ctx.validate();\n    \n    // this line will execute only if there aren't any errors\n    return {'greeting': `Hello ${ctx.req.name}`};\n  }\n}\n```\n\n### API\n\n- `checkRequest(field)`. Checks the field in the request. Field is an string that can be simple, nested, contain arrays, or be a [jsonpath](https://github.com/dchester/jsonpath):\n\n  - `simple`: When the property you want to check is `ctx.req.simple`\n  - `nested.field`: When the property you want to check is `ctx.req.nested.field`\n  - `other[0].field`: When the property you want to check is `ctx.req.other[0].field`\n  - `$.another[0].field`: When you want to use json path to access the property. See `[jsonpath](https://github.com/dchester/jsonpath)` documentation for more information.\n\n- `checkMetadata(field, [index])`: Checks the filed in the authorization metadata. If no index provided, index 0 will be used.\n- `validate([code], [message])`: Validates if there are any errors in `ctx.errors`.\n\nIf there are one or more errors, `ctx.validate()` will throw an error with `INVALID_ARGUMENT` code, and the `ctx.errors` object in the detail, finishing the request. \n\nThe user will receive an error like:\n\n```json\n{\n  \"code\": 3,\n  \"details\": \"{\\\"name\\\": \\\"Name cannot be empty\\\", \\\"other.email\\\": \\\"Invalid email\\\"}\"\n}\n```\n\nIf you want to launch with another status code or with your own message, you can do it as well:\n\n```js\n// if there are errors, respond with cancelled status\nctx.validate(ctx.status.CANCELLED);\n\n// if there are errors, respond with cancelled status and custom message\nctx.validate(ctx.status.CANCELLED, 'Request cancelled by the server');\n\n// which is the same as\nif (ctx.errors) {\n  throw {\n    'code': ctx.status.CANCELLED,\n    'details': 'Request cancelled by server',\n  };\n}\n```\n\n### Validators\n\n`options`,`version` or `locale` please see [validator](https://github.com/chriso/validator.js)\n\n- **optional()** - the param may not in the params.if the param not exists,it has no error,no matter whether have other checker or not.\n- **empty([tip])** - the params can be a empty string.\n- **notEmpty([tip])** - check if the param is not empty.\n- **notBlank([tip])** - check if the param is not blank,use /^\\s*$/gi reg to check.\n- **match(pattern,[tip])** - pattern must be a RegExp instance ,eg. /abc/i\n- **notMatch(pattern,[tip])** - pattern must be a RegExp instance ,eg. /xyz/i\n- **ensure(assertion, [tip], [shouldBail])** if assertion is false,the asserting failed.\n- **ensureNot(assertion, [tip], [shouldBail])** if assertion is true,the asserting failed.\n- **isInt([tip],[options])** - check if the param is integer.\n- **isFloat([tip],[options])** - check if the param is float.\n- **isLength(min,[max],[tip])** - check the param length.\n- **len(min,[max],[tip])** - the abbreviation of isLength.\n- **isIn(arr,[tip])** - check if the param is in the array.\n- **in(arr,[tip])** - the abbreviation of isIn.\n- **eq(value,[tip])** - check if the param equal to the value.\n- **neq(value,[tip])** - check if the param not equal to the value.\n- **gt(num,[tip])** - check if the param great then the value.\n- **lt(num,[tip])** - check if the param less then the value.\n- **ge(num,[tip])** - check if the param great then or equal the value.\n- **le(num,[tip])** - check if the param less then or equal the value.\n- **contains(str,[tip])** - check if the param contains the str.\n- **notContains(str,[tip])** - check if the param not contains the str.\n- **isEmail([tip],[options])** - check if the param is an email.\n- **isUrl([tip],[options])** - check if the param is an URL.\n- **isIp([tip])** - check if the param is an IP (version 4 or 6).\n- **isAlpha([tip],[locale])** - check if the param contains only letters (a-zA-Z).\n- **isNumeric([tip])** - check if the param contains only numbers.\n- **isAlphanumeric([tip],[locale])** - check if the param contains only letters and numbers.\n- **isBase64([tip])** - check if a param is base64 encoded.\n- **isHexadecimal([tip])** - check if the param is a hexadecimal number.\n- **isHexColor([tip])** - check if the param is a hexadecimal color.\n- **isLowercase([tip])** - check if the param is lowercase.\n- **isUppercase([tip])** - check if the param is uppercase.\n- **isDivisibleBy(num,[tip])** - check if the param is a number that's divisible by another.\n- **isNull([tip])** - check if the param is null.\n- **isByteLength(min,max,[tip])** - check if the param's length (in bytes) falls in a range.\n- **byteLength(min,max,[tip])** - the abbreviation of isByteLength.\n- **isUUID([tip],[version])** - check if the param is a UUID (version 3, 4 or 5).\n- **isDate([tip])** - check if the param is a date.\n- **isAfter(date,[tip])** - check if the param is a date that's after the specified date.\n- **isBefore(date,[tip])** - check if the param is a date that's before the specified date.\n- **isCreditCard([tip])** - check if the param is a credit card.\n- **isISBN([tip],version)** - check if the param is an ISBN (version 10 or 13).\n- **isJSON([tip])** - check if the param is valid JSON (note: uses JSON.parse).\n- **isMultibyte([tip])** - check if the param contains one or more multibyte chars.\n- **isAscii([tip])** - check if the param contains ASCII chars only.\n- **isFullWidth([tip])** - check if the param contains any full-width chars.\n- **isHalfWidth([tip])** - check if the param contains any half-width chars.\n- **isVariableWidth([tip])** - check if the param contains a mixture of full and half-width chars\n- **isSurrogatePair([tip])** - check if the param contains any surrogate pairs chars.\n- **isCurrency([tip],[options])** - check if the param is a currency.\n- **isDataURI([tip])** - check if the param is a data uri.\n- **isMobilePhone([tip],[locale])** - check if the param is a mobile phone.\n- **isISO8601([tip])** - check if the param is a ISO8601 string. eg.2004-05-03\n- **isMACAddress([tip])** - check if the param is a MAC address.eg.C8:3A:35:CC:ED:80\n- **isISIN([tip])** - check if the param is a ISIN.\n- **isFQDN([tip],[options])** - check if the param is a fully qualified domain name. eg.www.google.com\n\n### For json path:\n\n- **check(fn,tip,scope)** - if fn return `false` then check failed.fn format `function(value,key,requestParams):boolean`\n- **filter(fn,scope)** - filter the value if value is array.fn format `function(value,index,key,requestParams):boolean`\n- **get(index)** - change the value to the specified index value\n- **first()** - get the first value!\n\n### Known issues\n\n- Sanitizers haven't been tested, and should not work, except maybe for simple fields.\n- json path options haven't been fully tested\n\n## Under the hood\n\nBuilt on top of `Validator` class of [koa-validate](https://github.com/RocksonZeta/koa-validate) module, which uses [validator](https://github.com/chriso/validator.js) module. Inspired on [express-validator](https://github.com/ctavan/express-validator) and [koa-validate](https://github.com/RocksonZeta/koa-validate).\n\nIn the future, we will use a differente `Validator` class in order to make sanitizers work.\n\n## License and Credits\n\nMIT License. Copyright 2017 \n\nBuilt by the [GRPC experts](https://devsu.com) at Devsu.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevsu%2Fcondor-validate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevsu%2Fcondor-validate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevsu%2Fcondor-validate/lists"}