{"id":26225521,"url":"https://github.com/benmelz/limitable","last_synced_at":"2025-08-30T15:15:52.028Z","repository":{"id":170810857,"uuid":"647062630","full_name":"benmelz/limitable","owner":"benmelz","description":"Inferred database limit validations for ActiveRecord.","archived":false,"fork":false,"pushed_at":"2025-04-03T20:02:38.000Z","size":92,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-28T01:39:40.228Z","etag":null,"topics":["activerecord","rails","ruby"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/limitable","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/benmelz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-05-30T01:35:27.000Z","updated_at":"2025-04-03T20:02:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"f7a7053f-cd01-4693-a6cb-2ffd69e8ee6e","html_url":"https://github.com/benmelz/limitable","commit_stats":null,"previous_names":["benmelz/limitable"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/benmelz/limitable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmelz%2Flimitable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmelz%2Flimitable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmelz%2Flimitable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmelz%2Flimitable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benmelz","download_url":"https://codeload.github.com/benmelz/limitable/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benmelz%2Flimitable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272866016,"owners_count":25006310,"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-30T02:00:09.474Z","response_time":77,"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":["activerecord","rails","ruby"],"created_at":"2025-03-12T19:17:04.750Z","updated_at":"2025-08-30T15:15:51.981Z","avatar_url":"https://github.com/benmelz.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Limitable\n\nLimitable scans your ActiveRecord database schema for column size limits and defines corresponding model validations\nso that you don't have to.\n\nIt aims to make your database schema the \"one source of truth\" about the maximum data sizes your columns can handle.\nMore practically, it removes the redundant need for explicit guards such as:\n\n```ruby\nvalidates :my_string_column, length: { less_than: 256 }\n\nvalidates :my_integer_column, numericality: { less_than: 2_147_483_647 }\n\nbegin\n  # ...\nrescue ActiveRecord::ValueTooLong\n  # ...\nend\n```\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n```shell\nbundle add limitable\n```\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n```shell\ngem install limitable\n```\n\n## Usage\n\nOnce included in a model, `Limitable` will scan `integer`, `string`, `text` and `binary` columns for size limits,\ndefining byte size validations accordingly. Limits are configurable through `ActiveRecord` migrations.\n\n### Quick Start\n\nTo enable database limit validations globally:\n\n```ruby\nclass ApplicationRecord \u003c ActiveRecord::Base\n  extend Limitable::Base\n\n  # ...\nend\n```\n\nTo enable database limit validations on a per-model basis:\n\n```ruby\nclass MyModel \u003c ApplicationRecord\n  include Limitable\n\n  # ...\nend\n```\n\n### Translations\n\n`Limitable` ships with i18n support for its validation error messages. Each column type has its own translation key,\noutlined alongside their default values in `lib/limitable/locale/en.yml`.\n\nEach validator will pass a `limit` parameter (min/max integer for integer columns, bytes for string/text/binary),\nwhich can be used to make the messages less ambiguous if desired.\n\ne.g.\n\n```yaml\nen:\n  limitable:\n    string_limit_exceeded: \"may not exceed %{limit} characters\"\n```\n\n### SQL Adapters\n\n`Limitable` is designed to be SQL adapter agnostic, however different adapters have different default behaviors that\naffect their integration with this library.\n\n#### `mysql2`\n\nMySQL/mariadb has and reports hard limits on all supported column types. As such, you won't need to specify explicit\nlimits in your database migrations/schema unless you want to change them from their default values.\n\n#### `pg`\n\nPostgreSQL has and reports hard limits on its integer columns, however it supports and defaults to unlimited\nstring/text/binary columns. If you wish for limits to be validated on those columns, they must be explicitly set in your\ndatabase migrations/schema.\n\n#### `sqlite3`\n\nSQLite has hard limits on most of its column types, but it does not report them to active record. If you wish for limits\nto be validated, they must be explicitly set in your database migrations/schema.\n\n## Development\n\n- Run `bin/setup` to install dependencies.\n- Run `bin/rake appraisal rspec` to run the tests.\n- Run `bin/rake rubocop` to run the linter.\n- Run `bin/console` for an interactive prompt that will allow you to experiment.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/benmelz/limitable.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenmelz%2Flimitable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenmelz%2Flimitable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenmelz%2Flimitable/lists"}