Add support for hexadecimal values for OptInt options
git-svn-id: file:///home/svn/framework3/trunk@4652 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
4dfa1f0b8f
commit
4d3a91f63b
|
@ -391,13 +391,17 @@ class OptInt < OptBase
|
|||
end
|
||||
|
||||
def normalize(value)
|
||||
value.to_i
|
||||
if (value.to_s.match(/^0x[a-fA-F\d]+$/))
|
||||
value.to_i(16)
|
||||
else
|
||||
value.to_i
|
||||
end
|
||||
end
|
||||
|
||||
def valid?(value)
|
||||
return false if empty_required_value?(value)
|
||||
|
||||
if value and value.to_s.match(/^\d+$/) == nil
|
||||
if value and not normalize(value).to_s.match(/^\d+$/)
|
||||
return false
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue