Class: WithUid::UidValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- WithUid::UidValidator
- Defined in:
- lib/with_uid/uid_validator.rb
Overview
Validates uid
Constant Summary collapse
- REGEX =
/\A[0-9a-z\-_\.]+\z/i
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/with_uid/uid_validator.rb', line 14 def validate_each(record, attribute, value) return if .fetch(:allow_blank, false) && value.blank? return if value =~ REGEX record.errors[attribute] << .fetch(:message, 'invalid format') end |