(format-cep cep)Formats a CEP with standard Brazilian mask (XXXXX-XXX).
Arguments: cep - String or number to format (formatted or unformatted)
Returns: A CEP string formatted with the mask (XXXXX-XXX)
Examples: (format-cep "01310100") ;; => "01310-100" (format-cep "01310-100") ;; => "01310-100" (format-cep "01310") ;; => "01310"
Formats a CEP with standard Brazilian mask (XXXXX-XXX). Arguments: cep - String or number to format (formatted or unformatted) Returns: A CEP string formatted with the mask (XXXXX-XXX) Examples: (format-cep "01310100") ;; => "01310-100" (format-cep "01310-100") ;; => "01310-100" (format-cep "01310") ;; => "01310"
(get-address-from-cep cep)Retrieves address information for a given CEP using ViaCEP API.
Args: cep (string): The CEP code (8 digits, with or without hyphen)
Returns: A map containing address information on success, or an error map on failure. Success: {:logradouro "street name", :bairro "neighborhood", :localidade "city", :uf "state"} Error: {:error error-message}
Examples: (get-address-from-cep "01310-100") (get-address-from-cep "01310100")
Retrieves address information for a given CEP using ViaCEP API.
Args:
cep (string): The CEP code (8 digits, with or without hyphen)
Returns:
A map containing address information on success, or an error map on failure.
Success: {:logradouro "street name", :bairro "neighborhood", :localidade "city", :uf "state"}
Error: {:error error-message}
Examples:
(get-address-from-cep "01310-100")
(get-address-from-cep "01310100")(get-cep-information-from-address logradouro localidade uf)Searches for CEP code by address information using ViaCEP API. Returns the first (most relevant) result.
This function queries the ViaCEP API to find a CEP based on street name, city, and state. The API may return multiple results, but this function returns only the first (most relevant) match.
Arguments: logradouro (string): Street name localidade (string): City name uf (string): State abbreviation (2 letters, e.g., "SP", "RJ")
Returns: A map with address information on success, or an error map on failure. Success: {:logradouro "street", :bairro "neighborhood", :localidade "city", :uf "state", :cep "12345-678", :ddd "11", :ibge "3550308"} Error: {:error error-message}
Examples: (get-cep-information-from-address "Avenida Paulista" "São Paulo" "SP") (get-cep-information-from-address "Rua Augusta" "São Paulo" "SP")
Searches for CEP code by address information using ViaCEP API.
Returns the first (most relevant) result.
This function queries the ViaCEP API to find a CEP based on street name, city, and state.
The API may return multiple results, but this function returns only the first (most relevant) match.
Arguments:
logradouro (string): Street name
localidade (string): City name
uf (string): State abbreviation (2 letters, e.g., "SP", "RJ")
Returns:
A map with address information on success, or an error map on failure.
Success: {:logradouro "street", :bairro "neighborhood", :localidade "city", :uf "state", :cep "12345-678", :ddd "11", :ibge "3550308"}
Error: {:error error-message}
Examples:
(get-cep-information-from-address "Avenida Paulista" "São Paulo" "SP")
(get-cep-information-from-address "Rua Augusta" "São Paulo" "SP")(is-valid? cep)Validates whether a CEP (postal code) is well-formed.
Checks:
Accepts both formatted (XXXXX-XXX) and unformatted (XXXXXXXX) CEPs.
Args: cep - CEP string to validate (formatted or unformatted)
Returns: true if valid; false otherwise
Examples: (is-valid? "01310-100") ;; true (is-valid? "01310100") ;; true (is-valid? "0131010") ;; false (7 digits) (is-valid? nil) ;; false
Validates whether a CEP (postal code) is well-formed. Checks: - Input is a string - Contains only digits and an optional hyphen in the correct position - Has exactly 8 digits - All characters are numeric (0-9) Accepts both formatted (XXXXX-XXX) and unformatted (XXXXXXXX) CEPs. Args: cep - CEP string to validate (formatted or unformatted) Returns: true if valid; false otherwise Examples: (is-valid? "01310-100") ;; true (is-valid? "01310100") ;; true (is-valid? "0131010") ;; false (7 digits) (is-valid? nil) ;; false
(remove-symbols cep)Removes all non-numeric characters from a CEP.
Normalizes CEP input by stripping hyphens and other symbols, returning only digits.
Args: cep - CEP string to normalize (formatted or unformatted); nil allowed
Returns: String with digits only (0-9); nil yields an empty string
Examples: (remove-symbols "01310-100") ;; => "01310100" (remove-symbols "01310100") ;; => "01310100" (remove-symbols nil) ;; => "" (remove-symbols "") ;; => ""
Removes all non-numeric characters from a CEP. Normalizes CEP input by stripping hyphens and other symbols, returning only digits. Args: cep - CEP string to normalize (formatted or unformatted); nil allowed Returns: String with digits only (0-9); nil yields an empty string Examples: (remove-symbols "01310-100") ;; => "01310100" (remove-symbols "01310100") ;; => "01310100" (remove-symbols nil) ;; => "" (remove-symbols "") ;; => ""
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |