Liking cljdoc? Tell your friends :D

brazilian-utils.cnh.core

Core utilities for CNH (Carteira Nacional de Habilitação).

Core utilities for CNH (Carteira Nacional de Habilitação).
raw docstring

is-valid?clj/s

(is-valid? cnh)

Validates a CNH (Carteira Nacional de Habilitação/National Driver License) number.

This function checks if the input is a valid Brazilian CNH by verifying:

  • It is a string
  • It contains exactly 11 digits (after cleaning formatting)
  • The check digits are correct according to the CNH algorithm

Accepts both formatted (XXXXX.XXXX.XXXX) and unformatted (XXXXXXXXXXX) CNHs.

Arguments: cnh - CNH string to validate (formatted or unformatted)

Returns: true if valid; false otherwise

Examples: (is-valid? "00000000191") ;; true/false depending on check digits (is-valid? "0000000019") ;; false (10 digits) (is-valid? nil) ;; false

Validates a CNH (Carteira Nacional de Habilitação/National Driver License) number.

This function checks if the input is a valid Brazilian CNH by verifying:
- It is a string
- It contains exactly 11 digits (after cleaning formatting)
- The check digits are correct according to the CNH algorithm

Accepts both formatted (XXXXX.XXXX.XXXX) and unformatted (XXXXXXXXXXX) CNHs.

Arguments:
  cnh - CNH string to validate (formatted or unformatted)

Returns:
  true if valid; false otherwise

Examples:
  (is-valid? "00000000191") ;; true/false depending on check digits
  (is-valid? "0000000019") ;; false (10 digits)
  (is-valid? nil)            ;; false
sourceraw docstring

remove-symbolsclj/s

(remove-symbols cnh)

Removes all non-numeric characters from a CNH.

This function normalizes CNH input by stripping formatting characters, returning only the digits.

Arguments: cnh - CNH string (formatted or unformatted); nil allowed

Returns: Digits-only string; nil yields an empty string

Examples: (remove-symbols "00000000191") ;; => "00000000191" (remove-symbols "0000000019") ;; => "0000000019" (remove-symbols nil) ;; => "" (remove-symbols "") ;; => ""

Removes all non-numeric characters from a CNH.

This function normalizes CNH input by stripping formatting characters,
returning only the digits.

Arguments:
  cnh - CNH string (formatted or unformatted); nil allowed

Returns:
  Digits-only string; nil yields an empty string

Examples:
  (remove-symbols "00000000191") ;; => "00000000191"
  (remove-symbols "0000000019")  ;; => "0000000019"
  (remove-symbols nil)               ;; => ""
  (remove-symbols "")            ;; => ""
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close