Before any manual climate record is persisted, ClimApp runs it through a set of validation functions defined inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/adrianaarang/climapp/llms.txt
Use this file to discover all available pages before exploring further.
utils/validators.py. The top-level validate_weather_data() function orchestrates all individual checks via all(), so every field must pass for the record to be accepted. The same validators are also used by AlertService before evaluating alert thresholds, ensuring that bad data cannot trigger false alerts.
validate_weather_data(data)
The main entry point. Takes a single dict and returnsTrue only if all five field validators pass.
Dictionary containing at minimum the keys
fecha, temperatura, humedad, viento, and lluvia. Any extra keys are ignored. Returns False immediately if data is None or not a dict.True if all validators return True, otherwise False.
Individual validators
validar_fecha(fecha_texto)
validar_fecha(fecha_texto)
Validates the observation date string. Returns
Before format matching the function strips any time component: it replaces
True if the value is non-empty and matches one of the three supported formats.Supported formats:| Format | Example |
|---|---|
DD/MM/YYYY | 29/04/2026 |
DD-MM-YYYY | 29-04-2026 |
YYYY-MM-DD | 2026-04-29 |
T with a space and takes only the part before the first space. This means ISO 8601 timestamps such as 2026-04-29T14:30:00 are reduced to 2026-04-29 before parsing.validar_temperatura(valor)
validar_temperatura(valor)
Validates an air temperature reading.
- Uses
comprobar_si_es_numero()to attempt float conversion. - Returns
Trueif the converted value is in the range -50.0 to 60.0 °C (inclusive). - Returns
Falseif the value isNone, empty, non-numeric, or outside the range.
-50.0 <= temperatura <= 60.0validar_humedad(valor)
validar_humedad(valor)
Validates a relative humidity percentage.
- Uses
comprobar_si_es_numero()to attempt float conversion. - Returns
Trueif the converted value is in the range 0 to 100 % (inclusive). - Returns
Falseif the value isNone, empty, non-numeric, or outside the range.
0 <= humedad <= 100validar_viento(valor)
validar_viento(valor)
Validates a wind speed measurement.
- Uses
comprobar_si_es_numero()to attempt float conversion. - Returns
Trueif the converted value is greater than or equal to 0. - Returns
Falseif the value isNone, empty, or negative.
viento >= 0There is no upper bound on wind speed. The only constraint is that the value must be a non-negative number.
validar_lluvia(valor)
validar_lluvia(valor)
Validates a rainfall measurement.
- Uses
comprobar_si_es_numero()to attempt float conversion. - Returns
Trueif the converted value is greater than or equal to 0. - Returns
Falseif the value isNone, empty, or negative.
lluvia >= 0There is no upper bound on rainfall. The only constraint is that the value must be a non-negative number.
comprobar_si_es_numero(valor, nombre) helper
All four numeric validators delegate type conversion to this helper. It performs a safefloat() cast and returns None on failure rather than raising an exception, making the individual validators safe to call with any input type.
The value to convert. Accepts numbers, numeric strings, or anything castable by
float(). None and blank strings return None without raising.Field name for contextual use (currently unused inside the function but accepted for API consistency and future logging).
float on success, or None if conversion fails.