Skip to content

Instantly share code, notes, and snippets.

@pbalduino
Forked from jlmferreira/validador.clj
Last active December 31, 2015 22:59
Show Gist options
  • Save pbalduino/8057334 to your computer and use it in GitHub Desktop.
Save pbalduino/8057334 to your computer and use it in GitHub Desktop.
(defn border [x]
(cond (= (meta x) nil) "nao autorizado"
(= ((meta x) :type) "valinor") x
:default "lixo"))
;Associar um meta a sua função de validação
;teste
(def x (with-meta [1 2 3 4] {:type "valinor"}))
(border x)
; => [1 2 3 4]
(border [1 2 3 4 5])
; => não autorizado
(def x (with-meta [1 2 3 4] {:type "outracoisa"}))
(border x)
; => lixo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment