8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/models/staypuft/deployment/vlan_range_values_validator.rb', line 8
def validate_each(record, attribute, value)
return if value.empty?
if value !~ /\A\d+:\d+\Z/
record.errors.add attribute, GENERAL_MSG
return
end
range_values = value.split(':').map(&:to_i)
range_values.all? do |value|
if value.between?(FIRST_VALID, LAST_VALID)
true
else
record.errors.add attribute, "Range boundary #{value} #{INT_VAL_MSG}"
false
end
end or return
unless range_values[1] >= range_values[0]
record.errors.add attribute, _("End VLAN ID must be equal to or greater than start VLAN ID.")
end
end
|