from owrx.form.input import Input from owrx.form.input.validator import Validator from owrx.form.error import ValidationError from owrx.config import Config import logging logger = logging.getLogger(__name__) class LocationValidator(Validator): def validate(self, key, value): if "lat" in value and not -90 < value["lat"] < 90: raise ValidationError(key, "Latitude out of range (-90 to 90)") if "lon" in value and not -180 < value["lon"] < 180: raise ValidationError(key, "Longitude out of range (-180 to 180)") pass class LocationInput(Input): def __init__(self, id, label, validator: Validator = None): if validator is None: validator = LocationValidator() super().__init__(id, label, validator=validator) def render_input_group(self, value, errors): return """