0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 07:50:43 -05:00

Add shape type validators.

This commit is contained in:
Andrey Antukh 2015-12-29 23:39:19 +02:00
parent 78f619b25d
commit 9072c816e8

View file

@ -14,22 +14,31 @@
[v] [v]
(cljs.core/keyword? v)) (cljs.core/keyword? v))
(v/defvalidator uuid (v/defvalidator uuid
"Validates maybe-an-int is a valid integer. "Validates maybe-an-int is a valid integer.
For use with validation functions such as `validate` or `valid?`" For use with validation functions such as `validate` or `valid?`"
{:default-message-format "%s must be a uuid instance" {:default-message-format "%s must be a uuid instance"}
:optinal true}
[v] [v]
(instance? cljs.core.UUID v)) (instance? cljs.core.UUID v))
(v/defvalidator color (v/defvalidator color
"Validates if a string is a valid color." "Validates if a string is a valid color."
{:default-message-format "%s must be a valid hex color" {:default-message-format "%s must be a valid hex color"}
:optional true}
[v] [v]
(not (nil? (re-find #"^#[0-9A-Fa-f]{6}$" v)))) (not (nil? (re-find #"^#[0-9A-Fa-f]{6}$" v))))
(v/defvalidator shape-type
"Validates if a keyword is a shape type."
{:default-message-format "%s must be a shape type keyword."}
[v]
(shape? v))
(v/defvalidator vector
"Validats if `v` is vector."
{:default-message-format "%s must be a vector instance."}
[v]
(vector? v))
(def required v/required) (def required v/required)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;