mirror of
https://github.com/technix/ham_radio.git
synced 2025-01-07 12:57:29 +01:00
better validation
This commit is contained in:
parent
139370227d
commit
c70315c038
@ -1,10 +1,9 @@
|
|||||||
function ham_radio.validate_frequency(frequency)
|
function ham_radio.validate_frequency(frequency)
|
||||||
if frequency == nil then
|
local num_freq = tonumber(frequency)
|
||||||
return false
|
|
||||||
end
|
|
||||||
local num_freq = math.floor(tonumber(frequency))
|
|
||||||
local freq = tostring(num_freq)
|
local freq = tostring(num_freq)
|
||||||
return freq == frequency
|
return freq == frequency
|
||||||
|
and num_freq ~= nil
|
||||||
|
and num_freq == math.floor(num_freq)
|
||||||
and num_freq >= ham_radio.settings.frequency.min
|
and num_freq >= ham_radio.settings.frequency.min
|
||||||
and num_freq <= ham_radio.settings.frequency.max
|
and num_freq <= ham_radio.settings.frequency.max
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user