lib/configit/attribute_definition.rb in configit-0.1.1 vs lib/configit/attribute_definition.rb in configit-0.1.2
- old
+ new
@@ -28,10 +28,12 @@
@required
end
# Returns an error string if the value is not valid per this AttributeDefinition
def validate(value)
- return "#{name} is a required attribute" if required? && value == nil || value == ""
+ if required? && (value == nil || value == "") && (default == nil || default == "")
+ return "#{name} is a required attribute"
+ end
# TODO: add type validation here
nil
end
end
end