Type: New Feature
Affects Version/s: core-1.2.0
Fix Version/s: None
Component/s: Isis Applib (programming model)
The reference implementation (Hibernate Validator) is Apache licensed .
Implementation: should not be too difficult; mostly a matter of writing some FacetFactories.
It may not make sense to use every feature of JSR-349...
- constructor parameters
- constraint groups
1. In Isis bootstrapping, get hold and cache the Validator. (This is thread-safe, so could perhaps be global; maybe as a new top-level component cf AuthorizationManager etc).
Validating a property change can be done using:
(nb: using validator.validateProperty(...) would mean that the value has been applied already).
eg this would be a facet that implements ValidatingInteractionAdvisor and acts on a ValidityContext of type PropertyModifyContext. (eg subclass PropertyValidateFacetAbstract)
2. Validating a parameter of an action can be done using:
This would be in a Facet that implements ValidatingInteractionAdvisor and acts on a ValidityContext of type ActionInvocationContext (eg subclass ActionValidationFacetAbstract)
There are also some new features that could be implemented:
3. validating the return value of an action:
This would need to be done after the action has been invoked; if the constraint failed, then an exception would be thrown causing the transaction to be aborted. This might require a new subclass of ValidityContext, eg ActionReturnValueContext.
ISIS-479, all dirtied objects should be validated prior to commit.
a) we re-validate all properties (using the value of the property as the proposed value). This would be done using InteractionUtils, called from isAssociationValid with a ValidityContext of PropertyModifyContext.
b) we validate the object, ie InteractionUtils, with all with a ValidityContext of ObjectValidityContext.
We would then have a new facet, implementing ValidatingInteractionAdvisor and acting on an ObjectValidityContext (eg subclass ValidateObjectFacetAbstract); which should perform: