GeoLeaf Core API - v3.0.0
    Preparing search index...

    Function validateCoordinates

    • Validates a latitude/longitude pair.

      Delegates the range check to the security module, so the bounds are the same ones the rest of the kernel enforces. Like every validator here, it reports by default and only throws when asked — which is what lets it be used directly in a condition.

      Parameters

      Returns { valid: boolean; error: string | null }

      { valid, error }; error is null when valid.

      GeoLeafError A ValidationError when the pair is invalid and throwOnError is set.

      // Coordonnées valides
      const result = GeoLeaf.Validators.validateCoordinates(45.5017, -73.5673);
      // Returns: { valid: true, error: null }

      // Latitude invalide (> 90)
      const result2 = GeoLeaf.Validators.validateCoordinates(95, -73);
      // Returns: { valid: false, error: 'Latitude must be between -90 and 90' }

      // Mode strict (lance exception)
      try {
      GeoLeaf.Validators.validateCoordinates(95, -73, { throwOnError: true });
      } catch (error) {
      console.error("Coordonnées invalides:", error.message);
      }