I have a model with an enum like this:
enum health_company: {
company_a: 0,
company_b: 1,
company_c: 2,
}
and a validation that should allow health company "company_c" only if the job is of type "job_x":
validates :health_company, exclusion: { in: %i(company_c) }, unless: proc{ employee.last_job.job_x? }
This validation is not working. What's the error? Is it even possible to exclude certain values from an enum based on a condition?