Search in sources :

Example 1 with CidrValidation

use of org.ovirt.engine.ui.uicommonweb.validation.CidrValidation in project ovirt-engine by oVirt.

the class ExternalSubnetModel method validate.

public boolean validate() {
    getName().validateEntity(new IValidation[] { new NotEmptyValidation(), new AsciiNameValidation() });
    boolean ipv4 = getIpVersion().getSelectedItem() == IpVersion.IPV4;
    getCidr().validateEntity(new IValidation[] { ipv4 ? new CidrValidation() : new NotEmptyValidation() });
    getIpVersion().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    getGateway().setIsValid(true);
    if (StringHelper.isNotNullOrEmpty(getGateway().getEntity()) && ipv4) {
        getGateway().validateEntity(new IValidation[] { new Ipv4AddressValidation() });
    }
    boolean dnsServersValid = true;
    for (EntityModel<String> dnsServer : getDnsServers().getItems()) {
        dnsServer.setIsValid(true);
        if (StringHelper.isNotNullOrEmpty(dnsServer.getEntity()) && ipv4) {
            dnsServer.validateEntity(new IValidation[] { new Ipv4AddressValidation() });
        }
        dnsServersValid &= dnsServer.getIsValid();
    }
    return getName().getIsValid() && getCidr().getIsValid() && getIpVersion().getIsValid() && getGateway().getIsValid() && dnsServersValid;
}
Also used : CidrValidation(org.ovirt.engine.ui.uicommonweb.validation.CidrValidation) Ipv4AddressValidation(org.ovirt.engine.ui.uicommonweb.validation.Ipv4AddressValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) AsciiNameValidation(org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation)

Aggregations

AsciiNameValidation (org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation)1 CidrValidation (org.ovirt.engine.ui.uicommonweb.validation.CidrValidation)1 Ipv4AddressValidation (org.ovirt.engine.ui.uicommonweb.validation.Ipv4AddressValidation)1 NotEmptyValidation (org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)1