Hi,
First additional patch. I added new validation option for parameters in Rabbit.
Now you can define param rule in this way:
param :name, :string, :required, { :format => /(\w{20})/}
etc...
I hope it will be usefull. (eg. for GoGrid name limit)
-- Michal
---
server/lib/deltacloud/validation.rb | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/server/lib/deltacloud/validation.rb
b/server/lib/deltacloud/validation.rb
index b4eb3ae..b26a52d 100644
--- a/server/lib/deltacloud/validation.rb
+++ b/server/lib/deltacloud/validation.rb
@@ -61,9 +61,16 @@ module Deltacloud::Validation
if p.required? and not values[p.name]
raise Failure.new(p, "Required parameter #{p.name} not found")
end
- if values[p.name] and not p.options.empty? and
- not p.options.include?(values[p.name])
- raise Failure.new(p, "Parameter #{p.name} has value #{values[p.name]}
which is not in #{p.options.join(", ")}")
+ if values[p.name] and not p.options.empty?
+ if p.options.class == Hash
+ if p.options[:format]
+ if values[p.name].match(Regexp.new(p.options[:format])).nil?
+ raise Failure.new(p, "Parameter #{p.name} has invalid format
(#{p.options[:format].inspect})")
+ end
+ end
+ elsif p.options.class == Array
+ raise Failure.new(p, "Parameter #{p.name} has value
#{values[p.name]} which is not in #{p.options.join(',')}") unless
p.options.include?(values[p.name])
+ end
end
end
end
--
1.7.1
--
--------------------------------------------------------
Michal Fojtik, [email protected], +420 532 294 4307
Ruby / Ruby On Rails Developer
Deltacloud API: http://deltacloud.org
--------------------------------------------------------
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel