summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/util/validators.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-05-04 16:57:00 +0900
committerRandy Morgan <[email protected]>2012-05-04 16:57:00 +0900
commit754e2226d618260c4895cf15e54f5c8190345f8e (patch)
treee1c433db807764c1816e1d823437009f3b3e35e3 /lib/axlsx/util/validators.rb
parent5d221c2e01336b8771d15cf89a87fcb0f6e424b5 (diff)
parent58effe424218aa8ba6aa8157b49233df05646308 (diff)
downloadcaxlsx-754e2226d618260c4895cf15e54f5c8190345f8e.tar.gz
caxlsx-754e2226d618260c4895cf15e54f5c8190345f8e.zip
Merge branch 'master' of github.com:randym/axlsx
Diffstat (limited to 'lib/axlsx/util/validators.rb')
-rw-r--r--lib/axlsx/util/validators.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/axlsx/util/validators.rb b/lib/axlsx/util/validators.rb
index 7b0a74a6..1ee0d75e 100644
--- a/lib/axlsx/util/validators.rb
+++ b/lib/axlsx/util/validators.rb
@@ -90,6 +90,22 @@ module Axlsx
DataTypeValidator.validate :float, Float, v
end
+ # Requires that the value is a string containing a positive decimal number followed by one of the following units:
+ # "mm", "cm", "in", "pt", "pc", "pi"
+ def self.validate_number_with_unit(v)
+ RegexValidator.validate "number_with_unit", /\A[0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi)\Z/, v
+ end
+
+ # Requires that the value is an integer ranging from 10 to 400.
+ def self.validate_page_scale(v)
+ DataTypeValidator.validate "page_scale", [Fixnum, Integer], v, lambda { |arg| arg >= 10 && arg <= 400 }
+ end
+
+ # Requires that the value is one of :default, :landscape, or :portrait.
+ def self.validate_page_orientation(v)
+ RestrictionValidator.validate "page_orientation", [:default, :landscape, :portrait], v
+ end
+
# Requires that the value is valid pattern type.
# valid pattern types must be one of :none, :solid, :mediumGray, :darkGray, :lightGray, :darkHorizontal, :darkVertical, :darkDown,
# :darkUp, :darkGrid, :darkTrellis, :lightHorizontal, :lightVertical, :lightDown, :lightUp, :lightGrid, :lightTrellis, :gray125, or :gray0625.