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;
}
Aggregations