Active_storage_validations

screenshot of Active_storage_validations
rails

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 }

Overview:

Active Storage Validations is a gem that simplifies the process of adding validations to files attached using the active_storage gem in Rails. It provides a range of features including validation for content type, size, dimensions, number of files, aspect ratio, and more. The gem allows for custom error messages and supports dynamic determination of values using procs.

Features:

  • Validates if file(s) are attached
  • Validates content type
  • Validates size of files
  • Validates dimension of images/videos
  • Validates number of uploaded files
  • Validates aspect ratio
  • Custom error messages
  • Allows procs for dynamic determination of values
rails
Ruby on Rails

Ruby on Rails, often referred to as Rails, is an open-source web application framework written in Ruby. Known for its convention over configuration and don't repeat yourself (DRY) principles, Rails simplifies and accelerates the development of database-backed web applications.