ankane / str_enum

String enums for Rails

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ability to specify validation message?

gregblass opened this issue · comments

Hey there! I was wondering if there is a way to specify the validation messaging. 'is not included in the list' doesn't quite fit the standard messaging for other fields in Rails.

In other words - all my other fields have validation messaging like "can't be blank" - but because one of the fields on the model is a str_enum, it has different messaging, which isn't quite a uniform experience to the user.

Is this possible?

image

It's weird...looking through the source code...I don't even see any case where you are specifying that language. So then it must actually be a rails thing?

I see where it's happening - right here:

validate_options = {inclusion: {in: values}}

I wonder if its possible to pass in something to override that?

Hey @gregblass, agree it makes more sense for the presence validation message to come before the inclusion message. Just pushed the change to master. Can you give it a shot?

Closing due to no response

Hey I’m so sorry, I could have sworn I responded here. Thank you so much man - I’ll give it a shot today!

No worries, released 0.2.0 with the change.