Skip to main content

Documentation 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.

Before any manual climate record is persisted, ClimApp runs it through a set of validation functions defined in 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 returns True only if all five field validators pass.
def validate_weather_data(data):
    if not data or not isinstance(data, dict):
        return False

    return all([
        validar_fecha(data.get("fecha")),
        validar_temperatura(data.get("temperatura")),
        validar_humedad(data.get("humedad")),
        validar_viento(data.get("viento")),
        validar_lluvia(data.get("lluvia"))
    ])
data
object
required
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.
Returns True if all validators return True, otherwise False.

Individual validators

Validates the observation date string. Returns True if the value is non-empty and matches one of the three supported formats.Supported formats:
FormatExample
DD/MM/YYYY29/04/2026
DD-MM-YYYY29-04-2026
YYYY-MM-DD2026-04-29
Before format matching the function strips any time component: it replaces 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.
Dates must be in one of the three supported formats above. Any other separator or ordering (e.g. MM/DD/YYYY or YYYY/MM/DD) will fail validation even if the date is logically valid. ISO 8601 timestamps are stripped to date-only before parsing, so the time part is not validated.
Validates an air temperature reading.
  • Uses comprobar_si_es_numero() to attempt float conversion.
  • Returns True if the converted value is in the range -50.0 to 60.0 °C (inclusive).
  • Returns False if the value is None, empty, non-numeric, or outside the range.
Valid range: -50.0 <= temperatura <= 60.0
Validates a relative humidity percentage.
  • Uses comprobar_si_es_numero() to attempt float conversion.
  • Returns True if the converted value is in the range 0 to 100 % (inclusive).
  • Returns False if the value is None, empty, non-numeric, or outside the range.
Valid range: 0 <= humedad <= 100
Validates a wind speed measurement.
  • Uses comprobar_si_es_numero() to attempt float conversion.
  • Returns True if the converted value is greater than or equal to 0.
  • Returns False if the value is None, empty, or negative.
Valid range: viento >= 0
There is no upper bound on wind speed. The only constraint is that the value must be a non-negative number.
Validates a rainfall measurement.
  • Uses comprobar_si_es_numero() to attempt float conversion.
  • Returns True if the converted value is greater than or equal to 0.
  • Returns False if the value is None, empty, or negative.
Valid range: lluvia >= 0
There 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 safe float() cast and returns None on failure rather than raising an exception, making the individual validators safe to call with any input type.
valor
any
required
The value to convert. Accepts numbers, numeric strings, or anything castable by float(). None and blank strings return None without raising.
nombre
string
required
Field name for contextual use (currently unused inside the function but accepted for API consistency and future logging).
Returns the value as a float on success, or None if conversion fails.
def comprobar_si_es_numero(valor, nombre):
    try:
        if valor is None or str(valor).strip() == "":
            return None
        return float(valor)
    except (ValueError, TypeError):
        return None

Build docs developers (and LLMs) love