mirror of
https://github.com/penpot/penpot.git
synced 2025-07-31 09:58:31 +02:00
WIP: project creation now work.
This commit is contained in:
parent
62b9267d4f
commit
56f7613453
11 changed files with 201 additions and 103 deletions
30
frontend/uxbox/schema.cljs
Normal file
30
frontend/uxbox/schema.cljs
Normal file
|
@ -0,0 +1,30 @@
|
|||
(ns uxbox.schema
|
||||
(:refer-clojure :exclude [keyword?])
|
||||
(:require [bouncer.core :as b]
|
||||
[bouncer.validators :as v]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Validators
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(v/defvalidator keyword?
|
||||
"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 keyword"}
|
||||
[v]
|
||||
(cljs.core/keyword? v))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Public Api
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn validate
|
||||
([schema] #(validate schema %))
|
||||
([schema data] (first (b/validate data schema))))
|
||||
|
||||
(defn validate!
|
||||
([schema] #(validate! schema %))
|
||||
([schema data]
|
||||
(when-let [errors (validate schema data)]
|
||||
(throw (ex-info "Invalid data" errors)))))
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue