Class: BsonObjectIdValidations::LegalBsonObjectIdValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- BsonObjectIdValidations::LegalBsonObjectIdValidator
- Defined in:
- lib/bson_object_id_validations/legal_bson_object_id_validator.rb
Constant Summary collapse
- @@error_message =
'is not a legal BSON::ObjectId'
Instance Method Summary collapse
-
#validate_each(record, attribute, value) ⇒ Object
Validate that the specified attribute’s value is a legal BSON::ObjectId .
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
Validate that the specified attribute’s value is a legal BSON::ObjectId .
29 30 31 32 33 34 35 |
# File 'lib/bson_object_id_validations/legal_bson_object_id_validator.rb', line 29 def validate_each(record, attribute, value) = [:message] || @@error_message unless ::BSON::ObjectId.legal? value record.errors.add attribute, end end |