Merge pull request #235 from jancona/hpsdr_config
Set proper config options for HPSDR connector
This commit is contained in:
@ -109,8 +109,8 @@ class TextInput(Input):
|
||||
|
||||
|
||||
class NumberInput(Input):
|
||||
def __init__(self, id, label, infotext=None, append="", converter: Converter = None):
|
||||
super().__init__(id, label, infotext, converter=converter)
|
||||
def __init__(self, id, label, infotext=None, append="", converter: Converter = None, validator: Validator = None):
|
||||
super().__init__(id, label, infotext, converter=converter, validator=validator)
|
||||
self.step = None
|
||||
self.append = append
|
||||
|
||||
|
@ -12,3 +12,15 @@ class RequiredValidator(Validator):
|
||||
def validate(self, key, value):
|
||||
if value is None or value == "":
|
||||
raise ValidationError(key, "Field is required")
|
||||
|
||||
class RangeValidator(Validator):
|
||||
def __init__(self, minValue, maxValue):
|
||||
self.minValue = minValue
|
||||
self.maxValue = maxValue
|
||||
|
||||
def validate(self, key, value):
|
||||
if value is None or value == "":
|
||||
return # Ignore empty values
|
||||
n = float(value)
|
||||
if n < self.minValue or n > self.maxValue:
|
||||
raise ValidationError(key, 'Value must be between %s and %s'%(self.minValue, self.maxValue))
|
||||
|
Reference in New Issue
Block a user