You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optionaly you can set the "canonical list" of categories. It provides
185
+
two additional functionalities
186
+
* if a field contains a category which is not listed in the list,
187
+
that will be excluded (with a warning in the log)
188
+
* the order of the categories in the output follows the order set
189
+
in the configuration.
190
+
191
+
Here is an example (in YAML):
192
+
193
+
```yaml
194
+
format: json
195
+
...
196
+
categories:
197
+
- MANDATORY
198
+
- DESCRIPTIVENESS
199
+
- SEARCHABILITY
200
+
- IDENTIFICATION
201
+
- CUSTOM
202
+
- MULTILINGUALITY
203
+
204
+
```
205
+
## Constraints
206
+
207
+
One can add constraints to the fields. There are content rules, which
208
+
the tool will check. In this version the tool mimin SHACL constraints.
209
+
210
+
### Cardinality
211
+
*`minCount <number>` - specifies the minimum number of field occurence (API: `setMinCount()` or `withMinCount()`)
212
+
*`maxCount <number>` - specifies the maximum number of field occurence (API: `setMaxCount()` or `withMaxCount()`)
213
+
214
+
### Value Range
215
+
216
+
*`minExclusive <number>` - The minimum exclusive value ([field value] > limit, API: `setMinExclusive(Double)` or `withMinExclusive(Double)`)
217
+
*`minInclusive <number>` - The minimum inclusive value ([field value] >= limit, API: `setMinInclusive(Double)` or `withMinExclusive(Double)`)
218
+
*`maxExclusive <number>` - The maximum exclusive value ([field value] < limit, API: `setMaxExclusive(Double)` or `withMaxExclusive(Double)`)
219
+
*`maxInclusive <number>` - The maximum inclusive value ([field value] <= limit, API: `setMaxInclusive(Double)` or `withMaxInclusive(Double)`)
220
+
221
+
### String constraints
222
+
223
+
*`minLength <number>` - The minimum string length of each field value (API: `setMinLength(Integer)` or `withMinLength(Integer)`)
224
+
*`maxLength <number>` - The maximum string length of each field value (API: `setMinLength(Integer)` or `withMaxLength(Integer)`)
225
+
*`pattern <regular expression>` - A regular expression that each field value matches to satisfy the condition (API: `setPattern(String)` or `withPattern(String)`)
226
+
227
+
### Property pair
228
+
229
+
*`equals <field label>` - The set of all values of a field is equal to the set of all values of another field
230
+
(API: `setEquals(String)` or `withEquals(String)`)
231
+
*`disjoint <field label>` - The set of values of a field is disjoint (not equal) with the set of all values of another field
232
+
(API: `setDisjoint(String)` or `withDisjoint(String)`)
233
+
*`lessThan <field label>` - Each values of a field is smaller than each values of another field
234
+
(API: `setLessThan(String)` or `withLessThan(String)`)
235
+
*`lessThanOrEquals <field label>` - Each values of a field is smaller than or equals to each values of another field
236
+
(API: `setLessThanOrEquals(String)` or `withLessThanOrEquals(String)`)
237
+
238
+
### Set rules
239
+
240
+
Via API
241
+
```java
242
+
Schema schema =newBaseSchema()
243
+
.setFormat(Format.CSV)
244
+
.addField(
245
+
newJsonBranch("title", "title")
246
+
.setRule(
247
+
newRule()
248
+
.withDisjoint("description")
249
+
)
250
+
)
251
+
.addField(
252
+
newJsonBranch("url", "url")
253
+
.setRule(
254
+
newRule()
255
+
.withMinCount(1)
256
+
.withMaxCount(1)
257
+
.withPattern("^https?://.*$")
258
+
)
259
+
)
260
+
;
261
+
```
262
+
263
+
Via configuration file (a YAML example):
264
+
265
+
```yaml
266
+
format: csv
267
+
fields:
268
+
- name: title
269
+
categories: [MANDATORY]
270
+
rules:
271
+
disjoint: description
272
+
- name: url
273
+
categories: [MANDATORY]
274
+
extractable: true
275
+
rules:
276
+
minCount: 1
277
+
maxCount: 1
278
+
pattern: ^https?://.*$
279
+
```
280
+
281
+
In both cases we defined two fields. `title` has one constraints: it should not be equal to
282
+
the value of `description` field (which is masked out from the example). Note: if this hypothetical
283
+
`description`field is not available the API drops an error message into the log. `url` should have
284
+
one and only one instance, and its value should start with "http://" or "https://".
285
+
286
+
As you can see there are two types of setters in the API: setSomething and withSomething. The
287
+
difference is that setSomething returs with void, but withSomething returns with the Rule object,
288
+
so you can use it in a chain such as `new Rule().withMinCount(1).withMaxCount(3)`
0 commit comments