2019-03-04 13:36:34 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ShaValidator < ActiveModel::EachValidator
|
|
|
|
def validate_each(record, attribute, value)
|
2019-03-14 06:05:17 -04:00
|
|
|
return if value.blank? || Commit.valid_hash?(value)
|
2019-03-04 13:36:34 -05:00
|
|
|
|
|
|
|
record.errors.add(attribute, 'is not a valid SHA')
|
|
|
|
end
|
|
|
|
end
|