use of io.spine.validate.ConstraintViolation in project core-java by SpineEventEngine.
the class EventValidator method validate.
@Override
public Optional<MessageInvalid> validate(EventEnvelope envelope) {
checkNotNull(envelope);
final Event event = envelope.getOuterObject();
MessageInvalid result = null;
final List<ConstraintViolation> violations = messageValidator.validate(event);
if (!violations.isEmpty()) {
result = onConstraintViolations(event, violations);
}
return Optional.fromNullable(result);
}
use of io.spine.validate.ConstraintViolation in project core-java by SpineEventEngine.
the class CommandValidator method isCommandValid.
private Optional<MessageInvalid> isCommandValid(CommandEnvelope envelope) {
final Command command = envelope.getCommand();
final List<ConstraintViolation> violations = inspect(envelope);
InvalidCommandException exception = null;
if (!violations.isEmpty()) {
exception = onConstraintViolations(command, violations);
commandBus.commandStore().storeWithError(command, exception);
}
return Optional.<MessageInvalid>fromNullable(exception);
}
Aggregations