You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Validate the size of the attribute is within a `min` and/or `max`
#
# ```
# validate_size_of age, min: 18, max: 100
# validate_size_of account_balance, min: 500
# ```
def validate_size_of(
attribute : Avram::Attribute,
min = nil,
max = nil,
allow_nil : Bool = false
)
if !min.nil? && !max.nil? && min > max
raise ImpossibleValidation.new(
attribute: attribute.name,
message: "size greater than #{min} but less than #{max}")
end
unless allow_nil && attribute.value.nil?
size = attribute.value.to_s.size
The text was updated successfully, but these errors were encountered:
The comments here confuse whether validate_size_of is supposed to validate the numeric value of something, or the size of something. This produces incorrect documentation at https://luckyframework.github.io/avram/Avram/Validations.html#validate_size_of(attribute:Avram::Attribute,min=nil,max=nil,allow_nil:Bool=false)-instance-method
This is also reflected in the incorrect documentation in the guides on the web site, see luckyframework/website#489
The text was updated successfully, but these errors were encountered: