{"id":17134587,"url":"https://github.com/jagaapple/grape-extra_validators","last_synced_at":"2025-03-24T06:17:02.446Z","repository":{"id":36945574,"uuid":"232559178","full_name":"jagaapple/grape-extra_validators","owner":"jagaapple","description":"Extra validators for Grape.","archived":false,"fork":false,"pushed_at":"2022-05-16T11:48:16.000Z","size":44,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T09:49:05.677Z","etag":null,"topics":["grape","ruby","validator"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/jagaapple.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-08T12:32:28.000Z","updated_at":"2020-09-30T23:24:32.000Z","dependencies_parsed_at":"2022-08-09T09:30:25.717Z","dependency_job_id":null,"html_url":"https://github.com/jagaapple/grape-extra_validators","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jagaapple%2Fgrape-extra_validators","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jagaapple%2Fgrape-extra_validators/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jagaapple%2Fgrape-extra_validators/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jagaapple%2Fgrape-extra_validators/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jagaapple","download_url":"https://codeload.github.com/jagaapple/grape-extra_validators/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245217946,"owners_count":20579300,"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":["grape","ruby","validator"],"created_at":"2024-10-14T19:45:09.661Z","updated_at":"2025-03-24T06:17:02.426Z","avatar_url":"https://github.com/jagaapple.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eGrape Extra Validators\u003c/h1\u003e\n\n\u003ch4 align=\"center\"\u003e🛡 Extra validators for Grape. 🍇\u003c/h4\u003e\n\n```rb\nparams do\n  requires :name, type: String, length: 4..32\n  requires :age, type: Integer, minimum_value: 0\n  requires :website, type: String, start_with: %w(http:// https://)\nend\n```\n\n\u003cdiv align=\"center\"\u003e\n\u003ca href=\"https://rubygems.org/gems/grape-extra_validators\"\u003e\u003cimg src=\"https://img.shields.io/gem/v/grape-extra_validators\" alt=\"gem\"\u003e\u003c/a\u003e\n\u003ca href=\"https://circleci.com/gh/jagaapple/grape-extra_validators\"\u003e\u003cimg src=\"https://img.shields.io/circleci/project/github/jagaapple/grape-extra_validators/master.svg\" alt=\"CircleCI\"\u003e\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/jagaapple/grape-extra_validators\"\u003e\u003cimg src=\"https://img.shields.io/codecov/c/github/jagaapple/grape-extra_validators.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opensource.org/licenses/MIT\"\u003e\u003cimg src=\"https://img.shields.io/github/license/jagaapple/grape-extra_validators.svg\" alt=\"license\"\u003e\u003c/a\u003e\n\u003ca href=\"https://twitter.com/jagaapple_tech\"\u003e\u003cimg src=\"https://img.shields.io/badge/contact-%40jagaapple_tech-blue.svg\" alt=\"@jagaapple_tech\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n## Table of Contents\n\n\u003c!-- TOC depthFrom:2 --\u003e\n\n- [Table of Contents](#table-of-contents)\n- [Quick Start](#quick-start)\n  - [Requirements](#requirements)\n  - [Installation](#installation)\n- [Validators](#validators)\n  - [For String](#for-string)\n    - [Length](#length)\n    - [Maximum Length](#maximum-length)\n    - [Minimum Length](#minimum-length)\n    - [Start With](#start-with)\n    - [End With](#end-with)\n  - [For Numeric](#for-numeric)\n    - [Value](#value)\n    - [Maximum Value](#maximum-value)\n    - [Minimum Value](#minimum-value)\n- [Contributing to grape-extra_validators](#contributing-to-grape-extra_validators)\n- [License](#license)\n\n\u003c!-- /TOC --\u003e\n\n\n## Quick Start\n### Requirements\n- Ruby 2.5 or higher\n- Grape 1.0.0 or higher\n\n### Installation\n```bash\n$ gem install grape-extra_validators\n```\n\nIf you are using Bundler, add the gem to Gemfile.\n\n```bash\ngem \"grape-extra_validators\"\n```\n\n\n## Validators\n### For String\n#### Length\nThe length validator checks whether the parameter is a specified characters length or within a specified characters length\nrange. You can specify an Integer or Range object to this.\n\n```rb\nparams do\n  requires :name, type: String, length: 4\n  requires :bio, type: String, length: 4..512\nend\n```\n\n#### Maximum Length\nThe maximum length validator checks whether the parameter is up to a specified characters length. You can specify an Integer\nobject to this.\n\n```rb\nparams do\n  requires :username, type: String, maximum_length: 20\nend\n```\n\n#### Minimum Length\nThe minimum length validator checks whether the parameter is at least a specified characters length. You can specify an Integer\nobject to this.\n\n```rb\nparams do\n  requires :username, type: String, minimum_length: 20\nend\n```\n\n#### Start With\nThe start with length validator checks whether the parameter starts with a specified string. You can specify a String, Symbol,\nor Array which has strings object to this.\n\n```rb\nparams do\n  requires :website, type: String, start_with: \"https://\"\n  requires :website, type: String, start_with: %w(http:// https://)\nend\n```\n\n#### End With\nThe end with length validator checks whether the parameter ends with a specified string. You can specify a String, Symbol,\nor Array which has strings object to this.\n\n```rb\nparams do\n  requires :price, type: String, end_with: \"JPY\"\n  requires :price, type: String, end_with: %w(JPY USD)\nend\n```\n\n### For Numeric\n#### Value\nThis gem does not support a validator which checks whether the parameter is within a specified range. You can use\n[`values` built-in validator](https://github.com/ruby-grape/grape#values) instead.\n\n```rb\nparams do\n  requires :point, type: Integer, values: 0..100\nend\n```\n\n#### Maximum Value\nThe maximum value validator checks whether the parameter is equal to or below a specified value. You can specify a Numeric\nobject to this.\n\n```rb\nparams do\n  requires :level, type: Integer, maximum_value: 5\nend\n```\n\nYou can pass a Proc object and request parameters are given as the first argument.\n\n```rb\nparams do\n  requires :level, type: Integer, maximum_value: -\u003e(params) { params[:foo] + 1 }\nend\n```\n\n#### Minimum Value\nThe minimum value validator checks whether the parameter is equal to or above a specified value. You can specify a Numeric\nobject to this.\n\n```rb\nparams do\n  requires :age, type: Integer, minimum_value: 0\nend\n```\n\nYou can pass a Proc object and request parameters are given as the first argument.\n\n```rb\nparams do\n  requires :level, type: Integer, minimum_value: -\u003e(params) { params[:bar] - 1 }\nend\n```\n\n\n## Contributing to grape-extra_validators\nBug reports and pull requests are welcome on GitHub at\n[https://github.com/jagaapple/grape-extra_validators](https://github.com/jagaapple/grape-extra_validators). This project\nis intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the\n[Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\nPlease read [Contributing Guidelines](./.github/CONTRIBUTING.md) before development and contributing.\n\n\n## License\nThe library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\nCopyright 2020 Jaga Apple. All rights reserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjagaapple%2Fgrape-extra_validators","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjagaapple%2Fgrape-extra_validators","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjagaapple%2Fgrape-extra_validators/lists"}