Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple allowed aspect ratios #339

Closed
armchairdj opened this issue Jan 1, 2025 · 1 comment
Closed

Support multiple allowed aspect ratios #339

armchairdj opened this issue Jan 1, 2025 · 1 comment
Labels
question Further information is requested

Comments

@armchairdj
Copy link

It doesn't appear to be possible to allow, say, a portrait or square image but not a landscape one.

I'm looking for the ability to do this:

validates :my_image, aspect_ratio: { in: %i[portrait square] }

Seems like the aspect ratio validator would need to be refactored to allow this.

I'd write a PR for this if the maintainers agreed it would be a useful feature.

@Mth0158
Copy link
Collaborator

Mth0158 commented Jan 1, 2025

Hi @armchairdj,
Actually it is possible since 1.4.0, we did not reflect the change in the readme though. The v2 version of the gem will be released in the coming days with the change in the readme, so no need to update it.
Let me know if you have any issues with the feature, you can use it like:

validates :my_image, aspect_ratio: { in: %i[portrait square] }
# or
validates :my_image, aspect_ratio: %i[portrait square]

@Mth0158 Mth0158 added the question Further information is requested label Jan 1, 2025
@Mth0158 Mth0158 closed this as completed Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants