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:
parent
78f619b25d
commit
9072c816e8
1 changed files with 14 additions and 5 deletions
|
@ -14,22 +14,31 @@
|
|||
[v]
|
||||
(cljs.core/keyword? v))
|
||||
|
||||
|
||||
(v/defvalidator uuid
|
||||
"Validates maybe-an-int is a valid integer.
|
||||
For use with validation functions such as `validate` or `valid?`"
|
||||
{:default-message-format "%s must be a uuid instance"
|
||||
:optinal true}
|
||||
{:default-message-format "%s must be a uuid instance"}
|
||||
[v]
|
||||
(instance? cljs.core.UUID v))
|
||||
|
||||
(v/defvalidator color
|
||||
"Validates if a string is a valid color."
|
||||
{:default-message-format "%s must be a valid hex color"
|
||||
:optional true}
|
||||
{:default-message-format "%s must be a valid hex color"}
|
||||
[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)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
|
Loading…
Reference in a new issue