{"id":23421149,"url":"https://github.com/nhsdigital/activemodel-caution","last_synced_at":"2026-03-08T10:37:02.620Z","repository":{"id":1736149,"uuid":"40002473","full_name":"NHSDigital/activemodel-caution","owner":"NHSDigital","description":"ActiveModel non-blocking warning gem","archived":false,"fork":false,"pushed_at":"2025-09-22T19:55:53.000Z","size":118,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-09-22T21:25:47.906Z","etag":null,"topics":[],"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/NHSDigital.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-07-31T11:34:41.000Z","updated_at":"2025-09-22T19:46:30.000Z","dependencies_parsed_at":"2023-02-13T19:47:34.039Z","dependency_job_id":"fddf250f-5a90-4f0d-bfeb-369d33dcdba7","html_url":"https://github.com/NHSDigital/activemodel-caution","commit_stats":null,"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"purl":"pkg:github/NHSDigital/activemodel-caution","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Factivemodel-caution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Factivemodel-caution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Factivemodel-caution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Factivemodel-caution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NHSDigital","download_url":"https://codeload.github.com/NHSDigital/activemodel-caution/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Factivemodel-caution/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005458,"owners_count":26083898,"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-10-10T02:00:06.843Z","response_time":62,"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-12-23T02:14:10.956Z","updated_at":"2025-10-10T22:04:05.914Z","avatar_url":"https://github.com/NHSDigital.png","language":"Ruby","readme":"# Warnings for ActiveModel [![Build Status](https://github.com/NHSDigital/activemodel-caution/workflows/Test/badge.svg)](https://github.com/NHSDigital/activemodel-caution/actions?query=workflow%3Atest)\n\nThe activemodel-caution gem mirrors ActiveModel's validation framework to provide non-blocking warnings.\nIt is possible to specify a warning as 'active', in which case it must be confirmed (otherwise a\nvalidation error is raised).\n\nThe codebase is heavily based on the ActiveModel's Validation framework.\n\n## Installation\n\n### With Bundler\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'activemodel-caution', :git =\u003e 'https://github.com/NHSDigital/activemodel-caution.git'\n```\n\nAnd then execute:\n\n    $ bundle\n\n### From Source\n\nOr install it yourself by cloning the project, then executing:\n\n    $ gem build activemodel-caution.gemspec\n    $ gem install ./activemodel-caution-1.0.3.gem\n\n## Usage\n\n## Basic\n\nBasic usage is similar to ActiveModel's validations:\n\n```ruby\nclass Post \u003c ActiveRecord::Base\n  caution :warn_against_empty_content\n\n  private\n\n  def warn_against_empty_content\n    warnings.add(:content, 'is blank') if content.blank?\n  end\nend\n\n@post = Post.new(title: 'My first blog', content: '')\n@post.valid?  #=\u003e true\n@post.safe?   #=\u003e false\n@post.unsafe? #=\u003e true\n@post.warnings.messages #=\u003e { :content =\u003e ['Content is blank'] }\n```\n\n### Active Warnings\n\nAlso included are \"active warnings\", which trigger a validation error until they are confirmed:\n\n```ruby\nclass Post \u003c ActiveRecord::Base\n  caution :actively_warn_against_empty_content\n\n  private\n\n  def actively_warn_against_empty_content\n    warnings.add(:content, 'is blank', active: true) if content.blank?\n  end\nend\n\n@post = Post.new(title: 'My first blog', content: '')\n@post.valid?  #=\u003e false\n@post.safe?   #=\u003e false\n@post.unsafe? #=\u003e true\n@post.warnings.active #=\u003e { :content =\u003e ['Content is blank'] }\n@post.errors[:base]   #=\u003e 'The following warnings need confirmation: Content is blank'\n```\n\nThe object must then be \"confirmed as safe\" to be valid:\n\n```ruby\n@post.warnings_need_confirmation? #=\u003e true\n@post.confirmed_safe? #=\u003e false\n\n@post.active_warnings_confirm_decision = true\n\n# We no longer are waiting for a decision...\n@post.warnings_need_confirmation? #=\u003e false\n# ...and the decision was, in this case, positive:\n@post.confirmed_safe? #=\u003e true\n\n@post.valid?  #=\u003e true\n@post.safe?   #=\u003e false\n```\n\n## Development\n\n### Synchronising updates\n\nThis repository aims to mirror the validations of `ActiveModel` / `ActiveRecord` in both functionality and implementation.\nAs such, releases are tagged to mirror Rails' own. The file `version.rb` defines both `RAILS_VERSION` and `GEM_VERSION` -\nthe latter of which can be use to release intermediate updates should they be necessary.\n\nChanges needing mirroring can be found with e.g. the below, although it's wise to review the full changelogs in detail too.\n\n```\nrails$ git diff v6.0.0.rc1..v6.0.0.rc2 --stat -- {activemodel/lib/active_model,activerecord/lib/active_record}/{error,validat}*\n```\n\n### Contributing\n\n1. Fork it ( https://github.com/NHSDigital/activemodel-caution/fork )\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n\nPlease note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.\n\n### Testing\n\nDevelopment dependencies can be installed using bundler in the usual way.\nTests can be run with\n\n    $ bundle exec rake\n\nThey currently use an in-memory SQLite database when testing the ActiveRecord integration.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhsdigital%2Factivemodel-caution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhsdigital%2Factivemodel-caution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhsdigital%2Factivemodel-caution/lists"}