6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/valideizer/rules.rb', line 6
def validate(value, rule, constraint)
begin
case rule
when :eql then validate_eql value, constraint
when :gt then validate_gt value, constraint
when :gte then validate_gte value, constraint
when :lt then validate_lt value, constraint
when :lte then validate_lte value, constraint
when :ot then validate_ot value, constraint
when :range then validate_range value, constraint
when :enum then validate_enum value, constraint
when :type then validate_type value, constraint
when :array_type then validate_array_type value, constraint
when :custom_type then validate_custom_type value, constraint
when :regexp then validate_regexp value, constraint
when :length then validate_length value, constraint
when :active_record then validate_active_record value, constraint
when :format then validate_time_format value, constraint
else true
end
rescue
false
end
end
|