git-svn-id: https://dev.finn.de/svn/cockpit/branches/reporting_merge@1837 7926756e-e54e-46e6-9721-ed318f58905epull/6827/head
parent
9645da6f9a
commit
e98365ee0e
@ -0,0 +1,31 @@ |
||||
module CostQuery::Validation |
||||
module CostQuery::Validation::DateValidation |
||||
include CostQuery::Validation |
||||
|
||||
def validate(*values) |
||||
errors.clear |
||||
values.all? do |vals| |
||||
vals = vals.is_a?(Array) ? vals : [vals] |
||||
vals.all? do |val| |
||||
begin |
||||
!!val.to_dateish |
||||
rescue ArgumentError |
||||
validate(vals - [val]) |
||||
errors << "\'#{val}\' is not a valid date!" |
||||
false |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
|
||||
def validate(*values) |
||||
true |
||||
end |
||||
|
||||
def errors |
||||
@errors ||= [] |
||||
@errors |
||||
end |
||||
|
||||
end |
Loading…
Reference in new issue