Attributes
errors | [R] |
Returns an array of validation errors created on file assignment in the |
Public Class methods
new(**options)
Initializes validation errors to an empty array.
[show source]
# File lib/shrine/plugins/validation.rb 27 def initialize(**options) 28 super 29 @errors = [] 30 end
Public Instance methods
attach(io, validate: nil, **options)
Performs validations after attaching file.
[show source]
# File lib/shrine/plugins/validation.rb 40 def attach(io, validate: nil, **options) 41 result = super(io, **options) 42 validation(validate) 43 result 44 end
attach_cached(value, validate: nil, **options)
Performs validations after attaching cached file.
[show source]
# File lib/shrine/plugins/validation.rb 33 def attach_cached(value, validate: nil, **options) 34 result = super(value, validate: false, **options) 35 validation(validate) 36 result 37 end
validate(**options)
Runs the validation defined by Attacher.validate
.
[show source]
# File lib/shrine/plugins/validation.rb 47 def validate(**options) 48 errors.clear 49 _validate(**options) if attached? 50 end