Search in sources :

Example 1 with TimeValidator

use of io.jmix.ui.component.validation.time.TimeValidator in project jmix by jmix-framework.

the class PastOrPresentValidator method accept.

@Override
public void accept(T value) throws ValidationException {
    // consider null value is valid
    if (value == null) {
        return;
    }
    TimeValidator timeConstraint = ValidatorHelper.getTimeConstraint(timeSource, value);
    if (timeConstraint == null) {
        throw new IllegalArgumentException("PastOrPresentValidator doesn't support following type: '" + value.getClass() + "'");
    }
    timeConstraint.setCheckSeconds(checkSeconds);
    if (!timeConstraint.isPastOrPresent()) {
        String message = getMessage();
        if (message == null) {
            message = messages.getMessage("validation.constraints.pastOrPresent");
        }
        throw new ValidationException(message);
    }
}
Also used : ValidationException(io.jmix.ui.component.ValidationException) TimeValidator(io.jmix.ui.component.validation.time.TimeValidator)

Example 2 with TimeValidator

use of io.jmix.ui.component.validation.time.TimeValidator in project jmix by jmix-framework.

the class PastValidator method accept.

@Override
public void accept(T value) throws ValidationException {
    // consider null value is valid
    if (value == null) {
        return;
    }
    TimeValidator timeConstraint = ValidatorHelper.getTimeConstraint(timeSource, value);
    if (timeConstraint == null) {
        throw new IllegalArgumentException("PastValidator doesn't support following type: '" + value.getClass() + "'");
    }
    timeConstraint.setCheckSeconds(checkSeconds);
    if (!timeConstraint.isPast()) {
        String message = getMessage();
        if (message == null) {
            message = messages.getMessage("validation.constraints.past");
        }
        throw new ValidationException(message);
    }
}
Also used : ValidationException(io.jmix.ui.component.ValidationException) TimeValidator(io.jmix.ui.component.validation.time.TimeValidator)

Example 3 with TimeValidator

use of io.jmix.ui.component.validation.time.TimeValidator in project jmix by jmix-framework.

the class FutureOrPresentValidator method accept.

@Override
public void accept(T value) throws ValidationException {
    // consider null value is valid
    if (value == null) {
        return;
    }
    TimeValidator timeConstraint = ValidatorHelper.getTimeConstraint(timeSource, value);
    if (timeConstraint == null) {
        throw new IllegalArgumentException("FutureOrPresentValidator doesn't support following type: '" + value.getClass() + "'");
    }
    timeConstraint.setCheckSeconds(checkSeconds);
    if (!timeConstraint.isFutureOrPresent()) {
        String message = getMessage();
        if (message == null) {
            message = messages.getMessage("validation.constraints.futureOrPresent");
        }
        throw new ValidationException(message);
    }
}
Also used : ValidationException(io.jmix.ui.component.ValidationException) TimeValidator(io.jmix.ui.component.validation.time.TimeValidator)

Example 4 with TimeValidator

use of io.jmix.ui.component.validation.time.TimeValidator in project jmix by jmix-framework.

the class FutureValidator method accept.

@Override
public void accept(T value) throws ValidationException {
    // consider null value is valid
    if (value == null) {
        return;
    }
    TimeValidator timeConstraint = ValidatorHelper.getTimeConstraint(timeSource, value);
    if (timeConstraint == null) {
        throw new IllegalArgumentException("FutureValidator doesn't support following type: '" + value.getClass() + "'");
    }
    timeConstraint.setCheckSeconds(checkSeconds);
    if (!timeConstraint.isFuture()) {
        String message = getMessage();
        if (message == null) {
            message = messages.getMessage("validation.constraints.future");
        }
        throw new ValidationException(message);
    }
}
Also used : ValidationException(io.jmix.ui.component.ValidationException) TimeValidator(io.jmix.ui.component.validation.time.TimeValidator)

Aggregations

ValidationException (io.jmix.ui.component.ValidationException)4 TimeValidator (io.jmix.ui.component.validation.time.TimeValidator)4