Search in sources :

Example 6 with RegexValidation

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

the class NetworkFilterParameterModel method validate.

public void validate() {
    RegexValidation nameValidation = new RegexValidation();
    // $NON-NLS-1$
    nameValidation.setExpression("^[a-zA-Z0-9_]+$");
    RegexValidation valueValidation = new RegexValidation();
    // $NON-NLS-1$
    valueValidation.setExpression("^[a-zA-Z0-9_\\.:]+$");
    name.validateEntity(new IValidation[] { new NotEmptyValidation(), nameValidation });
    value.validateEntity(new IValidation[] { new NotEmptyValidation(), valueValidation });
    setIsValid(name.getIsValid() && value.getIsValid());
}
Also used : RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)

Example 7 with RegexValidation

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

the class ConfigureLocalStorageModel method validate.

public boolean validate() {
    RegexValidation validation = new RegexValidation();
    // $NON-NLS-1$
    validation.setExpression("^[A-Za-z0-9_-]+$");
    validation.setMessage(ConstantsManager.getInstance().getConstants().asciiNameValidationMsg());
    getFormattedStorageName().validateEntity(new IValidation[] { validation });
    if (getFormattedStorageName().getEntity() != null && Linq.firstOrNull(context.storageList, new Linq.NamePredicate(getFormattedStorageName().getEntity())) != null) {
        getFormattedStorageName().setIsValid(false);
        getFormattedStorageName().getInvalidityReasons().add(ConstantsManager.getInstance().getConstants().nameMustBeUniqueInvalidReason());
    }
    boolean isStorageValid = getStorage().validate() && getFormattedStorageName().getIsValid();
    boolean isDataCenterValid = true;
    if (getCandidateDataCenter() == null) {
        isDataCenterValid = getDataCenter().validate();
    }
    boolean isClusterValid = true;
    if (getCandidateCluster() == null) {
        getCluster().validateName();
        isClusterValid = getCluster().getName().getIsValid();
    }
    setValidTab(TabName.GENERAL_TAB, isStorageValid && isDataCenterValid && isClusterValid);
    ValidationCompleteEvent.fire(getEventBus(), this);
    return isStorageValid && isDataCenterValid && isClusterValid;
}
Also used : RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) Linq(org.ovirt.engine.ui.uicommonweb.Linq)

Example 8 with RegexValidation

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

the class RoleModel method validate.

public boolean validate() {
    RegexValidation tempVar = new RegexValidation();
    // $NON-NLS-1$
    tempVar.setExpression("^\\w.{0,125}$");
    tempVar.setMessage(ConstantsManager.getInstance().getConstants().nameMustBeUpToAndStartWithMsg());
    RegexValidation tempVar2 = new RegexValidation();
    // $NON-NLS-1$
    tempVar2.setExpression("^[A-Za-z0-9_-]+$");
    tempVar2.setMessage(ConstantsManager.getInstance().getConstants().asciiNameValidationMsg());
    getName().validateEntity(new IValidation[] { new NotEmptyValidation(), tempVar, tempVar2 });
    LengthValidation lengthValidation = new LengthValidation();
    lengthValidation.setMaxLength(4000);
    getDescription().validateEntity(new IValidation[] { lengthValidation });
    return getName().getIsValid() && getDescription().getIsValid();
}
Also used : RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation)

Example 9 with RegexValidation

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

the class LibvirtSecretModel method validate.

public boolean validate() {
    getUsageType().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    getUuid().validateEntity(new IValidation[] { new NotEmptyValidation(), new GuidValidation() });
    ArrayList<IValidation> valueValidations = new ArrayList<>(Collections.singletonList(new RegexValidation(ValidationUtils.BASE_64_PATTERN, ConstantsManager.getInstance().getConstants().secretValueMustBeInBase64())));
    if (isNew()) {
        valueValidations.add(new NotEmptyValidation());
        getValue().validateEntity(valueValidations.toArray(new IValidation[valueValidations.size()]));
    }
    return getUsageType().getIsValid() && getUuid().getIsValid() && getValue().getIsValid();
}
Also used : GuidValidation(org.ovirt.engine.ui.uicommonweb.validation.GuidValidation) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) ArrayList(java.util.ArrayList) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)

Aggregations

RegexValidation (org.ovirt.engine.ui.uicommonweb.validation.RegexValidation)9 NotEmptyValidation (org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)6 ArrayList (java.util.ArrayList)3 Linq (org.ovirt.engine.ui.uicommonweb.Linq)3 IValidation (org.ovirt.engine.ui.uicommonweb.validation.IValidation)3 Arrays (java.util.Arrays)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)2 ActionType (org.ovirt.engine.core.common.action.ActionType)2 AddSANStorageDomainParameters (org.ovirt.engine.core.common.action.AddSANStorageDomainParameters)2 AttachStorageDomainToPoolParameters (org.ovirt.engine.core.common.action.AttachStorageDomainToPoolParameters)2 StorageDomainManagementParameter (org.ovirt.engine.core.common.action.StorageDomainManagementParameter)2 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StorageDomainSharedStatus (org.ovirt.engine.core.common.businessentities.StorageDomainSharedStatus)2 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)2 StorageDomainStatus (org.ovirt.engine.core.common.businessentities.StorageDomainStatus)2