commit
6d72b5b19f
|
@ -15,15 +15,17 @@ class OptInt < OptBase
|
|||
def normalize(value)
|
||||
if value.to_s.match(/^0x[a-fA-F\d]+$/)
|
||||
value.to_i(16)
|
||||
else
|
||||
elsif value.present?
|
||||
value.to_i
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def valid?(value, check_empty: true)
|
||||
return false if check_empty && empty_required_value?(value)
|
||||
|
||||
if value and not value.to_s.match(/^0x[0-9a-fA-F]+$|^-?\d+$/)
|
||||
if value.present? and not value.to_s.match(/^0x[0-9a-fA-F]+$|^-?\d+$/)
|
||||
return false
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class OptPort < OptInt
|
|||
end
|
||||
|
||||
def valid?(value, check_empty: true)
|
||||
port = normalize(value)
|
||||
port = normalize(value).to_i
|
||||
super && port <= 65535 && port >= 0
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue