Add constraints to the core
nillable : applied to every elements
pattern : applied to string and numerics
length/minLength/maxLength : applied to string and numerics
minExclusive, maxEclusive, minInclusive, maxInclusive : applied to numerics and dates
enumeration : applied to all types except boolean (which is an enumeration)
Add a way to get a CoreSession which would validate saved DocumentModel
For each (checked using unit tests) :
Using Validation API, I can validate a DocumentModel and a DataModel
Using Validation API, I can validate a Map<String, Object> by giving schema name (map key are field names)
Using Validation API, I can validate a Map<String, Object> (map key are schema names + ‘:’ + field names)
Using Validation API, I can validate an Object by giving a field name
Validation API should throw structured exception while validating wrong datas
Core API should allow any component to get constraints description - example :
Migration mode : do nothing | remove if not compliant
Migration : add a way to get no compliant datas
NB : I really appreciate the way Jenkins migrate this kind of problematic datas (It shows invalid data and propose to remove them but kept them with a specific screen to manage that)
Before using the Validation API, we need to build it.
The validate method of the Constraint interface is supposed to be called by validate method of the TypeImpl.
We need to have a way that allows to have the validate method called automatically :
doing a listener is an option
I would prefer add some code inside abstractSession for create/save Document
=> I would validate the way the validation will work before going further.
nico: bullet “Add a way to get a CoreSession which would validate saved DocumentModel” moved to top
nico: After a first AbstractSession based implementation, I would provide a DataValidationService used by the AbstractSession and provided to other components (code design should be better)
Tiry : That’s indeed go to have a DocumentValidationService that is separated from the AbstractSession so that we can call it directly if needed.