{"id":26780818,"url":"https://github.com/gitobi/subdomain_validation","last_synced_at":"2025-08-18T07:15:58.716Z","repository":{"id":59156763,"uuid":"55659472","full_name":"gitobi/subdomain_validation","owner":"gitobi","description":"Subdomain validator for Rails","archived":false,"fork":false,"pushed_at":"2016-04-10T08:45:11.000Z","size":40,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-28T17:46:35.228Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/gitobi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-07T03:08:03.000Z","updated_at":"2021-09-27T19:33:35.000Z","dependencies_parsed_at":"2022-09-13T20:11:28.378Z","dependency_job_id":null,"html_url":"https://github.com/gitobi/subdomain_validation","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/gitobi/subdomain_validation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitobi%2Fsubdomain_validation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitobi%2Fsubdomain_validation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitobi%2Fsubdomain_validation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitobi%2Fsubdomain_validation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gitobi","download_url":"https://codeload.github.com/gitobi/subdomain_validation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gitobi%2Fsubdomain_validation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270957964,"owners_count":24675289,"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-18T02:00:08.743Z","response_time":89,"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":"2025-03-29T07:18:12.020Z","updated_at":"2025-08-18T07:15:58.684Z","avatar_url":"https://github.com/gitobi.png","language":"Ruby","readme":"# SubdomainValidation\n\nSubdomain validator for Rails\n\n## Getting Started\n\nAdd subdomain_validation gem to your Gemfile.\n\n`gem 'subdomain_validation'`\n\nRun bundler.\n\n`bundle install`\n\n## How to use\n\nFirst, Add `SubdomainValidation` module to a model.\n\n```rb\nclass User \u003c ActiveRecord::Base\n  include SubdomainValidation\nend\n```\n\nNext, add `validates` method on a column in the model.\n\n```rb\nclass User \u003c ActiveRecord::Base\n  include SubdomainValidation\n\n  validates :username, subdomain: true\nend\n```\n\n## Validator Specifications\n\n- Be not nil.\n  - Allow by using allow_nil option\n- Be not blank.\n  - Allow by using allow_blank option\n- Be not reserved name.\n  - Customize by using reserved_name option\n- Be more than 3 characters.\n- Be less than or equal to 63 characters.\n- Be in alphanumeric and hyphen.\n- Do not start hyphen.\n- Do not end hyphen.\n\n### Reference\n\n[RFC 1035 - Domain names - implementation and specification](https://tools.ietf.org/html/rfc1035)\n\n### Default Settings\n\n- reserved_name\n  - The following name are prohibited to register by default. You can customize thease name.\n    - www\n    - http\n    - https\n    - ftp\n    - sftp\n    - ssl\n    - ns\n    - mx\n    - pop\n    - smtp\n    - admin\n    - mail\n    - users\n\n\n### Options\n\n- reserved_name\n  - Values: String Array or False\n  - String Array\n    - You can reserve the words which can not be taken.\n    - If use this option, then default reserved_name will be disabled.\n    - `validates :username, subdomain: { reserved_name: %w(www blog admin) }`\n  - False\n    - You can disable reserved_name feature.\n    - If use this option, then default reserved_name will be disabled.\n    - `validates :username, subdomain: { reserved_name: false }`\n- Common options\n  - allow_nil\n    - You can allow nil value by using allow_nil option.\n    - `validates :username, subdomain: true, allow_nil: true`\n  - allow_blank\n    - You can allow blank value by using allow_blank option.\n    - `validates :username, subdomain: true, allow_blank: true`\n  - on\n    - You can specify when the validation should happen.\n    - `validates :username, subdomain: true, on: :create`\n\n### I18n\n\nYou can customize or add validation error messages.\nAdd following keys to your locale file in config/locales.\n\n```yaml\nen:\n  subdomain_validation:\n    errors:\n      messages:\n        label:           \"can only include letters and numbers and \\\"-\\\"\"\n        first_character: \"can't start with \\\"-\\\"\"\n        last_character:  \"can't end with \\\"-\\\"\"\n```\n\nOr, make a pull request :)\n\n# License\n\nThis project rocks and uses MIT-LICENSE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitobi%2Fsubdomain_validation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgitobi%2Fsubdomain_validation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitobi%2Fsubdomain_validation/lists"}