Search in sources :

Example 6 with I18NNameValidation

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

the class ImportVmModel method validateName.

private boolean validateName(final ImportVmData data) {
    final int maxNameLength = getMaxNameLength();
    VmImportGeneralModel model = (VmImportGeneralModel) getDetailModels().get(0);
    EntityModel<String> vmName = new EntityModel<>(data.getVm().getName());
    vmName.validateEntity(new IValidation[] { new NotEmptyValidation(), new LengthValidation(maxNameLength), new I18NNameValidation(), new UniqueNameValidator(data), value -> isNameExistsInTheSystem(vmName.getEntity()) ? ValidationResult.fail(ConstantsManager.getInstance().getConstants().nameMustBeUniqueInvalidReason()) : ValidationResult.ok() });
    data.setError(vmName.getIsValid() ? null : ConstantsManager.getInstance().getConstants().invalidName());
    // Updating the 'name' model in general sub-tab
    model.getName().setInvalidityReasons(vmName.getInvalidityReasons());
    model.getName().setIsValid(vmName.getIsValid());
    return vmName.getIsValid();
}
Also used : EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) I18NNameValidation(org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation)

Aggregations

I18NNameValidation (org.ovirt.engine.ui.uicommonweb.validation.I18NNameValidation)6 NotEmptyValidation (org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)6 LengthValidation (org.ovirt.engine.ui.uicommonweb.validation.LengthValidation)4 DiskModel (org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)1 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)1 AsciiOrNoneValidation (org.ovirt.engine.ui.uicommonweb.validation.AsciiOrNoneValidation)1 SelectedQuotaValidation (org.ovirt.engine.ui.uicommonweb.validation.SelectedQuotaValidation)1 SpecialAsciiI18NOrNoneValidation (org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation)1