2019-03-13 22:55:13 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ShaValidator < ActiveModel::EachValidator
|
|
|
|
def validate_each(record, attribute, value)
|
2019-05-03 19:53:19 +05:30
|
|
|
return if value.blank? || Commit.valid_hash?(value)
|
2019-03-13 22:55:13 +05:30
|
|
|
|
|
|
|
record.errors.add(attribute, 'is not a valid SHA')
|
|
|
|
end
|
|
|
|
end
|