Codeminer42/cm42-central

View on GitHub
app/validators/central_estimate_validator.rb

Summary

Maintainability
A
0 mins
Test Coverage
class CentralEstimateValidator < ActiveModel::EachValidator
  # TODO: Change the name to EstimateValidator when remove support gem
  # Checks that the estimate being validated is valid for record.project
  def validate_each(record, attribute, value)
    if record.project
      unless record.project.point_values.include?(value)
        record.errors.add(attribute, message: 'is not an allowed value for this project')
      end
    end
  end
end