This library provides a number of convenience helpers for use with Reagent.
reagent.cookies
contains-key?
(contains-key? k)
is the key present in the cookies
contains-val?
(contains-val? v)
is the value present in the cookies (as string)
count
(count)
returns the number of cookies
empty?
(empty?)
true if no cookies are set
get
(get k & [default])
gets the value at the key (as edn), optional default when value is not found
get-raw
(get-raw k & [default])
gets the value at the key (as string), optional default when value is not found
keys
(keys)
returns all the keys for the cookies
raw-vals
(raw-vals)
returns cookie values (as strings)
remove!
(remove! k)
(remove! k path domain)
removes a cookie, optionally for a specific path and/or domain
set!
(set! k content & [{:keys [max-age path domain secure? raw?]} :as opts])
sets a cookie, the max-age for session cookie
following optional parameters may be passed in as a map:
:max-age - defaults to -1
:path - path of the cookie, defaults to the full request path
:domain - domain of the cookie, when null the browser will use the full request host name
:secure? - boolean specifying whether the cookie should only be sent over a secure channel
:raw? - boolean specifying whether content should be stored raw, or as EDN
vals
(vals)
returns cookie values (as edn)
reagent.crypt
bytes->hex
(bytes->hex bytes-in)
digest
(digest hasher bytes)
hash
(hash s hash-type & [hex?])
hash-bytes
(hash-bytes s hash-type)
string->bytes
(string->bytes s)
reagent.format
add-slashes
(add-slashes s)
capitalize-words
(capitalize-words s)
encode-uri
(encode-uri uri)
line-numbers
(line-numbers s)
pluralize
(pluralize items & [word ending1 ending2 :as opts])
pluralizes the word based on the number of items
(util/pluralize ["John"] "lad")
(util/pluralize ["John" "James"] "lad")
(util/pluralize ["Alice"] "lad" "y" "ies")
printf
(printf fmt & args)
Prints formatted output, as per format
reagent.validation
Functions for validating input and setting string errors on fields.
equal-to?
(equal-to? v n)
Returns true if the string represents a number = given.
greater-than?
(greater-than? v n)
Returns true if the string represents a number > given.
has-value?
(has-value? v)
Returns true if v is truthy and not an empty string.
has-values?
(has-values? coll)
Returns true if all members of the collection has-value? This works on maps as well.
is-email?
(is-email? v)
Returns true if v is an email address
less-than?
(less-than? v n)
Returns true if the string represents a number < given.
matches-regex?
(matches-regex? v regex)
Returns true if the string matches the given regular expression
max-length?
(max-length? v len)
Returns true if v is less than or equal to the given len
min-length?
(min-length? v len)
Returns true if v is greater than or equal to the given len
not-nil?
(not-nil? v)
Returns true if v is not nil
valid-number?
(valid-number? v)
Returns true if the string can be parsed to a Long