@Override
public String invalidates(final ValidityContext<? extends ValidityEvent> context) {
if (!(context instanceof PropertyModifyContext)) {
return null;
}
final PropertyModifyContext propertyModifyContext = (PropertyModifyContext) context;
ObjectAdapter proposed = propertyModifyContext.getProposed();
if(proposed == null) {
// skip validation if null value and optional property.
MandatoryFacet mandatoryFacet = getFacetHolder().getFacet(MandatoryFacet.class);
if(mandatoryFacet == null || mandatoryFacet.isNoop() || mandatoryFacet.isInvertedSemantics()) {
return null;
}
}
return invalidReason(propertyModifyContext.getTarget(), proposed);
}