This repository has been archived by the owner on Oct 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
protocols.cljs
69 lines (58 loc) · 1.59 KB
/
protocols.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
(ns re-frame-forms.protocols)
(defprotocol Value
"Protocol for value holder"
(value
[this default]
"Get reaction for current value")
(set-value!
[this val]
"Set current value"))
(defprotocol PersistentError
"Persistent error is retained between validations. Has to be explicitly set and cleared."
(set-error!
[this error]
"Set 1 error for the field. Error can be cleared by calling clear-error!"))
(defn clear-error!
"Clear field error"
[this]
(set-error! this nil))
(defprotocol ResetValue
"Protocol for accessing original value"
(original-value
[this]
"Get original value of the form/field")
(reset-value!
[this]
"Reset form/field to the original value, clear errors"))
(defprotocol CoercedValue
"Field protocol converting to/from string"
(str-value
[this]
"Get reaction for current value converted to string")
(set-str-value!
[this val retain-str?]
"Set current value by converting val from string"))
(defprotocol ErrorContainer
"Field/form errors"
(errors
[this]
"Get reaction for current field/form errors"))
(defprotocol Validatable
"Field/form validation status"
(valid?
[this]
"Get reaction for current validation status of the form/field"))
(defprotocol Touchable
"Protocol for forced validation."
(touch!
[this]
"Touch the field/form")
(touched?
[this]
"Get reaction with current touch status"))
(defprotocol DelayedValidation
(start-validation! [this])
(mark-ok! [this])
(mark-error! [this error]))
(defprotocol DelayValidationContainer
(validation-in-progress? [this]))