@@ -48,132 +48,5 @@ def self.limit_name
4848 raise NotImplementedError
4949 end
5050 end
51-
52- class MinLengthAttribute < LimitAttribute
53- def self . acceptable_type
54- String
55- end
56-
57- def self . limit_name
58- 'minLength'
59- end
60-
61- def self . error_message ( schema )
62- "was not of a minimum string length of #{ limit ( schema ) } "
63- end
64-
65- def self . value ( data )
66- data . length
67- end
68- end
69-
70- class MaxLengthAttribute < MinLengthAttribute
71- def self . limit_name
72- 'maxLength'
73- end
74-
75- def self . error_message ( schema )
76- "was not of a maximum string length of #{ limit ( schema ) } "
77- end
78- end
79-
80- class MinItemsAttribute < LimitAttribute
81- def self . acceptable_type
82- Array
83- end
84-
85- def self . value ( data )
86- data . length
87- end
88-
89- def self . limit_name
90- 'minItems'
91- end
92-
93- def self . error_message ( schema )
94- "did not contain a minimum number of items #{ limit ( schema ) } "
95- end
96- end
97-
98- class MaxItemsAttribute < MinItemsAttribute
99- def self . limit_name
100- 'maxItems'
101- end
102-
103- def self . error_message ( schema )
104- "had more items than the allowed #{ limit ( schema ) } "
105- end
106- end
107-
108- class MinPropertiesAttribute < LimitAttribute
109- def self . acceptable_type
110- Hash
111- end
112-
113- def self . value ( data )
114- data . size
115- end
116-
117- def self . limit_name
118- 'minProperties'
119- end
120-
121- def self . error_message ( schema )
122- "did not contain a minimum number of properties #{ limit ( schema ) } "
123- end
124- end
125-
126- class MaxPropertiesAttribute < MinPropertiesAttribute
127- def self . limit_name
128- 'maxProperties'
129- end
130-
131- def self . error_message ( schema )
132- "had more properties than the allowed #{ limit ( schema ) } "
133- end
134- end
135-
136- class NumericLimitAttribute < LimitAttribute
137- def self . acceptable_type
138- Numeric
139- end
140-
141- def self . error_message ( schema )
142- exclusivity = exclusive? ( schema ) ? 'exclusively' : 'inclusively'
143- format ( "did not have a %s value of %s, %s" , limit_name , limit ( schema ) , exclusivity )
144- end
145- end
146-
147- class MaximumAttribute < NumericLimitAttribute
148- def self . limit_name
149- 'maximum'
150- end
151-
152- def self . exclusive? ( schema )
153- schema [ 'exclusiveMaximum' ]
154- end
155- end
156-
157- class MaximumInclusiveAttribute < MaximumAttribute
158- def self . exclusive? ( schema )
159- schema [ 'maximumCanEqual' ] == false
160- end
161- end
162-
163- class MinimumAttribute < NumericLimitAttribute
164- def self . limit_name
165- 'minimum'
166- end
167-
168- def self . exclusive? ( schema )
169- schema [ 'exclusiveMinimum' ]
170- end
171- end
172-
173- class MinimumInclusiveAttribute < MinimumAttribute
174- def self . exclusive? ( schema )
175- schema [ 'minimumCanEqual' ] == false
176- end
177- end
17851 end
17952end
0 commit comments