13
13
import { lift2 } from "../../util/optional" ;
14
14
import { type Tag } from "../../stores/definitions/Tag" ;
15
15
16
- /*
16
+ /**
17
17
* The max length of an individual tag. Chosen rather arbitrarily based on the
18
18
* typically length of tags from the ontology file used for testing.
19
19
*/
@@ -44,7 +44,7 @@ opaque type TagValidation =
44
44
45
45
const forbiddenCharacters = new Set ( "<>\\" . split ( "" ) ) ;
46
46
47
- /*
47
+ /**
48
48
* Given a Tag, which is to say a simple string, there are some validations
49
49
* that can be performed on it alone.
50
50
*/
@@ -67,7 +67,7 @@ export const checkTagString = (tag: string): TagValidation => {
67
67
return { reason : "NoIssues" } ;
68
68
} ;
69
69
70
- /*
70
+ /**
71
71
* In addition to the restrictions above, a tag entered by the user also has
72
72
* some additional checks
73
73
*/
@@ -85,16 +85,16 @@ export const checkUserInputString = (tag: string): TagValidation => {
85
85
return checkTagString ( tag ) ;
86
86
} ;
87
87
88
- /*
88
+ type InternalTag = { |
89
+ ...Tag ,
90
+ selected : boolean ,
91
+ | } ;
92
+ /**
89
93
* Internal to the components for rendering the means with which a user may
90
94
* choose a tag, additional state is used to richly render these tags. This
91
95
* additional state gives us additional information with which to validate
92
96
* that a tag can be chosen.
93
97
*/
94
- type InternalTag = { |
95
- ...Tag ,
96
- selected : boolean ,
97
- | } ;
98
98
export const checkInternalTag = (
99
99
tag : InternalTag ,
100
100
{ enforceOntologies } : { enforceOntologies : boolean }
@@ -126,13 +126,19 @@ export const checkInternalTag = (
126
126
* =======================
127
127
*/
128
128
129
+ /**
130
+ * For disabling a tab based on the validation of a tag.
131
+ */
129
132
export const isAllowed = ( tagValidation : TagValidation ) : boolean => {
130
133
return (
131
134
tagValidation . reason === "NoIssues" ||
132
135
tagValidation . reason === "NoIssuesWithSourceInformation"
133
136
) ;
134
137
} ;
135
138
139
+ /**
140
+ * For explaining why a tag is not allowed.
141
+ */
136
142
export const helpText = ( tagValidation : TagValidation ) : ?string => {
137
143
if ( tagValidation . reason === "NoIssues" ) return null ;
138
144
if ( tagValidation . reason === "OntologiesAreEnforced" )
@@ -156,8 +162,3 @@ export const helpText = (tagValidation: TagValidation): ?string => {
156
162
return "Tags cannot contain consecutive whitespace characters." ;
157
163
}
158
164
} ;
159
-
160
- export const filterFieldError = ( tagValidation : TagValidation ) : ?string => {
161
- if ( tagValidation . reason === "NoIssues" ) return null ;
162
- return helpText ( tagValidation ) ;
163
- } ;
0 commit comments