# igorkasyanchuk/active_storage_validations

Do it like => validates :photos, attached: true, content_type: ['image/png', 'image/jpg', 'image/jpeg'], size: { less_than: 500.kilobytes }, limit: { min: 1, max: 3 }, aspect_ratio: :landscape, dimension: { width: { in: 800..1600 }

Repository: https://github.com/igorkasyanchuk/active_storage_validations
Canonical: https://ross.abutalabs.com/products/active_storage_validations
Homepage: https://www.igorkasyanchuk.com/
Language: Ruby
License: MIT
License Family: permissive
Topics: activestorage, validations, rails, active-storage
Last push: 2026-09-02T20:24:58+00:00

## Health v2 (maintenance only)
Score: 95/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 100, release rhythm 86, longevity 100
- inputs: {"age_days": 2927, "days_push": 0, "days_rel": 14, "gap_med": 36.5, "n_releases_24m": 19}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1191, forks 151 (observed 2026-09-03T02:15:12.872458+00:00)

## What it is
A Ruby gem that adds validations for Rails Active Storage attachments, such as attached presence, content type, file size, dimensions, aspect ratio, duration, and page count. It includes I18n error messages and RSpec/MiniTest test matchers.

## Use cases
- validate that an avatar attachment is present and is a PNG or JPEG
- limit number of uploaded photos to between 1 and 3
- enforce max file size on uploads
- check image dimensions and aspect ratio before accepting uploads
- validate video or audio duration in Active Storage
- prevent content type spoofing on uploaded files
- test attachment validations in Rails test suites

## When to choose
- you use Rails Active Storage and need declarative attachment validations
- you want built-in I18n error messages for upload validation failures
- you need metadata checks like image dimensions, aspect ratio, or media duration

## When to avoid
- you are not using Rails or Active Storage
- you need validation of files stored outside Active Storage
- you need a general-purpose file processing pipeline rather than validation

## Facets
- artifact type: library
- maturity: stable
- function: form-handling, file-upload, image-processing, testing
- domain: web-development, backend, files, developer-tools
- platform: ruby, cross-platform
- tags: rails, active-storage, activerecord, gem, file-validation, i18n, test-matchers, web-server

## Member repositories
- igorkasyanchuk/active_storage_validations (main) score 95

## Provenance
- Observed fields: from GitHub, fetched 2026-09-03T02:15:12.872458+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T06:23:02.199695+00:00, confidence not recorded.
  - readme: https://github.com/igorkasyanchuk/active_storage_validations (fetched 2026-09-03T02:15:12.872458+00:00, sha 56b31572df1c)
  - homepage: https://www.railsjazz.com/ (fetched 2026-08-29T12:30:05.884199+00:00, sha 08fc0beb8ec8)
- Data as of 2026-08-30T08:39:29.467469+00:00.
