You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
681 B
25 lines
681 B
(ns wanijo.tag.forms
|
|
(:require [clojure.spec.alpha :as spec]
|
|
[clojure.string :refer [split trim]]))
|
|
|
|
(defn contains-whitespace? [s]
|
|
(re-matches #".*\s.*" s))
|
|
|
|
(defn tag-names-from-input [s]
|
|
(->> (split s #",")
|
|
(map trim)))
|
|
|
|
(defn any-tag-name-contains-whitespace [s]
|
|
(some contains-whitespace? (tag-names-from-input s)))
|
|
|
|
(spec/def ::new-names
|
|
(spec/and string?
|
|
(complement empty?)
|
|
(complement any-tag-name-contains-whitespace)))
|
|
|
|
(def new-tag
|
|
{:fields {:newnames {:label "Tag Name(s)"
|
|
:required true
|
|
:spec ::new-names
|
|
:from-req tag-names-from-input}}})
|