當前位置: 首頁>>代碼示例>>Java>>正文


Java ValidationError類代碼示例

本文整理匯總了Java中play.data.validation.ValidationError的典型用法代碼示例。如果您正苦於以下問題:Java ValidationError類的具體用法?Java ValidationError怎麽用?Java ValidationError使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ValidationError類屬於play.data.validation包,在下文中一共展示了ValidationError類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: errorsAsJson

import play.data.validation.ValidationError; //導入依賴的package包/類
@Test
public void errorsAsJson() {
    running(fakeApplication(), new Runnable() {
        @Override
        public void run() {
            Lang lang = new Lang(new play.api.i18n.Lang("en", ""));
            
            Map<String, List<ValidationError>> errors = new HashMap<String, List<ValidationError>>();
            List<ValidationError> error = new ArrayList<ValidationError>();
            error.add(new ValidationError("foo", RequiredValidator.message, new ArrayList<Object>()));
            errors.put("foo", error);
            
            DynamicForm form = new DynamicForm(new HashMap<String, String>(), errors, F.None());
            
            JsonNode jsonErrors = form.errorsAsJson(lang);
            assertThat(jsonErrors.findPath("foo").iterator().next().asText()).isEqualTo(play.i18n.Messages.get(lang, RequiredValidator.message));
        }
    });
}
 
開發者ID:vangav,項目名稱:vos_backend,代碼行數:20,代碼來源:SimpleTest.java

示例2: validate

import play.data.validation.ValidationError; //導入依賴的package包/類
/**
 * Validate the dates.
 */
public List<ValidationError> validate() {

    List<ValidationError> errors = new ArrayList<>();

    if ((conditionalRuleFieldId.equals("") && !conditionalRuleFieldValue.equals(""))
            || (!conditionalRuleFieldId.equals("") && conditionalRuleFieldValue.equals(""))) {
        errors.add(new ValidationError("conditionalRuleFieldId", Messages.get("object.custom_attribute_definition.conditional_rule.invalid")));
    }

    if (attributeType.equals(ICustomAttributeValue.AttributeType.SCRIPT.name())) {
        try {
            ScriptCustomAttributeValue.validateScriptConfiguration(configuration);
        } catch (Exception e) {
            errors.add(new ValidationError("configuration", Messages.get("object.custom_attribute_definition.configuration.script.invalid", e.getMessage())));
        }
    }

    return errors.isEmpty() ? null : errors;
}
 
開發者ID:theAgileFactory,項目名稱:maf-desktop-app,代碼行數:23,代碼來源:CustomAttributeDefinitionFormData.java

示例3: validate

import play.data.validation.ValidationError; //導入依賴的package包/類
/**
 * Validate the dates.
 */
public List<ValidationError> validate() {

    List<ValidationError> errors = new ArrayList<>();

    try {

        if (Utilities.getDateFormat(null).parse(this.startDate).after(Utilities.getDateFormat(null).parse(this.endDate))) {
            // the end date should be after the start date
            errors.add(new ValidationError("endDate", Messages.get("object.data_syndication_agreement.end_date.invalid")));
        }

    } catch (Exception e) {
        Logger.warn("impossible to validate the dates");
    }

    return errors.isEmpty() ? null : errors;
}
 
開發者ID:theAgileFactory,項目名稱:maf-desktop-app,代碼行數:21,代碼來源:DataSyndicationAgreementNoSlaveSubmitFormData.java

示例4: validate

import play.data.validation.ValidationError; //導入依賴的package包/類
/**
 * Validate the dates.
 */
public List<ValidationError> validate() {

    List<ValidationError> errors = new ArrayList<>();

    if (this.startDate != null && this.dueDate != null) {

        try {

            if (!this.startDate.equals("") && !this.dueDate.equals("")
                    && Utilities.getDateFormat(null).parse(this.startDate).after(Utilities.getDateFormat(null).parse(this.dueDate))) {
                // the due date should be after the start date
                errors.add(new ValidationError("dueDate", Messages.get("object.work_order.due_date.invalid")));
            }

        } catch (Exception e) {
            Logger.warn("impossible to parse the dates when testing the formats");
        }
    }

    return errors.isEmpty() ? null : errors;
}
 
開發者ID:theAgileFactory,項目名稱:maf-desktop-app,代碼行數:25,代碼來源:WorkOrderFormData.java

示例5: validate

import play.data.validation.ValidationError; //導入依賴的package包/類
/**
 * Form validation.
 */
public List<ValidationError> validate() {

    List<ValidationError> errors = new ArrayList<>();

    // check the type is not already used by another milestone of the
    // process
    if (this.type != null && !this.type.equals("")) {
        LifeCycleMilestone otherMilestone = LifeCycleMilestoneDao.getLCMilestoneByProcessAndType(this.lifeCycleProcessId,
                LifeCycleMilestone.Type.valueOf(this.type));
        if (otherMilestone != null) {
            if (this.id != null) {
                // edit case
                if (!this.id.equals(otherMilestone.id)) {
                    errors.add(new ValidationError("type", Msg.get("object.life_cycle_milestone.type.invalid")));
                }
            } else {
                // create case
                errors.add(new ValidationError("type", Msg.get("object.life_cycle_milestone.type.invalid")));
            }
        }
    }

    return errors.isEmpty() ? null : errors;

}
 
開發者ID:theAgileFactory,項目名稱:maf-desktop-app,代碼行數:29,代碼來源:LifeCycleMilestoneFormData.java

示例6: validate

import play.data.validation.ValidationError; //導入依賴的package包/類
/**
 * Form validation.
 */
public List<ValidationError> validate() {

    List<ValidationError> errors = new ArrayList<>();

    // check the code is not already used
    Currency currency = CurrencyDAO.getCurrencyByCode(this.code);
    if (currency != null) {
        if (this.id != null) { // edit case
            if (!currency.id.equals(this.id)) {
                errors.add(new ValidationError("code", Msg.get("object.currency.code.error.already_used")));
            }
        } else { // new case
            errors.add(new ValidationError("code", Msg.get("object.currency.code.error.already_used")));
        }
    }

    return errors.isEmpty() ? null : errors;
}
 
開發者ID:theAgileFactory,項目名稱:maf-desktop-app,代碼行數:22,代碼來源:CurrencyFormData.java

示例7: validate

import play.data.validation.ValidationError; //導入依賴的package包/類
/**
 * Form validator.
 */
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList<>();

    if (actorId != null && ActorDao.getActorById(actorId) == null) {
        errors.add(new ValidationError("actorId", "The actor does not exist"));
    }
    if (portfolioId != null && PortfolioDao.getPortfolioById(portfolioId) == null) {
        errors.add(new ValidationError("portfolioId", "The portfolio does not exist"));
    }
    if (portfolioEntryId != null && PortfolioEntryDao.getPEById(portfolioEntryId) == null) {
        errors.add(new ValidationError("portfolioEntryId", "The portfolioEntry does not exist"));
    }
    if (stakeholderTypeId != null && StakeholderDao.getStakeholderTypeById(stakeholderTypeId) == null) {
        errors.add(new ValidationError("stakeholderTypeId", "The stakeholderType does not exist"));
    }

    return errors.isEmpty() ? null : errors;
}
 
開發者ID:theAgileFactory,項目名稱:maf-desktop-app,代碼行數:22,代碼來源:StakeholderListRequest.java

示例8: validate

import play.data.validation.ValidationError; //導入依賴的package包/類
/**
 * Form validator.
 */
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList<>();

    if (managerId != null && ActorDao.getActorById(managerId) == null) {
        errors.add(new ValidationError("managerId", "The manager does not exist"));
    }
    if (actorTypeId != null && ActorDao.getActorTypeById(actorTypeId) == null) {
        errors.add(new ValidationError("actorTypeId", "The actorType does not exist"));
    }
    if (competencyId != null && ActorDao.getCompetencyById(competencyId) == null) {
        errors.add(new ValidationError("competencyId", "The competency does not exist"));
    }
    if (orgUnitId != null && OrgUnitDao.getOrgUnitById(orgUnitId) == null) {
        errors.add(new ValidationError("orgUnitId", "The orgUnit does not exist"));
    }

    return errors.isEmpty() ? null : errors;

}
 
開發者ID:theAgileFactory,項目名稱:maf-desktop-app,代碼行數:23,代碼來源:ActorListRequest.java

示例9: validate

import play.data.validation.ValidationError; //導入依賴的package包/類
/**
 * Form validator.
 */
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList<>();

    if (managerId != null && ActorDao.getActorById(managerId) == null) {
        errors.add(new ValidationError("managerId", "The manager does not exist"));
    }
    if (parentId != null && OrgUnitDao.getOrgUnitById(parentId) == null) {
        errors.add(new ValidationError("parentId", "The parent does not exist"));
    }
    if (orgUnitTypeId != null && OrgUnitDao.getOrgUnitTypeById(orgUnitTypeId) == null) {
        errors.add(new ValidationError("orgUnitTypeId", "The orgUnitType does not exist"));
    }

    return errors.isEmpty() ? null : errors;
}
 
開發者ID:theAgileFactory,項目名稱:maf-desktop-app,代碼行數:19,代碼來源:OrgUnitListRequest.java

示例10: validate

import play.data.validation.ValidationError; //導入依賴的package包/類
/**
 * Form validator.
 * 
 * @throws AccountManagementException
 */
public List<ValidationError> validate() throws AccountManagementException {
    List<ValidationError> errors = new ArrayList<>();

    if (mafUid != null && accountManager.getUserAccountFromMafUid(mafUid) == null) {
        errors.add(new ValidationError("mafid", "The mafUid does not exist"));
    }
    if (uid != null && accountManager.getUserAccountFromUid(uid) == null) {
        errors.add(new ValidationError("uid", "The uid does not exist"));
    }
    if (mail != null && accountManager.getUserAccountFromEmail(mail) == null) {
        errors.add(new ValidationError("mail", "The mail does not exist"));
    }

    return errors.isEmpty() ? null : errors;

}
 
開發者ID:theAgileFactory,項目名稱:maf-desktop-app,代碼行數:22,代碼來源:UserListRequest.java

示例11: validate

import play.data.validation.ValidationError; //導入依賴的package包/類
/**
 * Form validator.
 */
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList<>();

    if (actorTypeId != null && ActorDao.getActorTypeById(actorTypeId) == null) {
        errors.add(new ValidationError("actorTypeId", "The actorType does not exist"));
    }

    if (orgUnitId != null && OrgUnitDao.getOrgUnitById(orgUnitId) == null) {
        errors.add(new ValidationError("orgUnitById", "The orgUnitBy does not exist"));
    }

    if (managerId != null && ActorDao.getActorById(managerId) == null) {
        errors.add(new ValidationError("managerId", "The manager does not exist"));
    }

    return errors.isEmpty() ? null : errors;

}
 
開發者ID:theAgileFactory,項目名稱:maf-desktop-app,代碼行數:22,代碼來源:ActorRequest.java

示例12: validate

import play.data.validation.ValidationError; //導入依賴的package包/類
/**
 * Form validator.
 */
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList<>();

    if (orgUnitTypeId != null && OrgUnitDao.getOrgUnitTypeById(orgUnitTypeId) == null) {
        errors.add(new ValidationError("orgUnitTypeId", "The orgUnitType does not exist"));
    }

    if (managerId != null && ActorDao.getActorById(managerId) == null) {
        errors.add(new ValidationError("managerId", "The manager does not exist"));
    }

    if (parentId != null && OrgUnitDao.getOrgUnitById(parentId) == null) {
        errors.add(new ValidationError("parentId", "The parent does not exist"));
    }

    return errors.isEmpty() ? null : errors;

}
 
開發者ID:theAgileFactory,項目名稱:maf-desktop-app,代碼行數:22,代碼來源:OrgUnitRequest.java

示例13: validate

import play.data.validation.ValidationError; //導入依賴的package包/類
/**
 * Form validator.
 */
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList<>();

    if (currencyId != null && CurrencyDAO.getCurrencyById(currencyId) == null) {
        errors.add(new ValidationError("currencyId", "The currencyId does not exist"));
    }
    if (supplierId != null && SupplierDAO.getSupplierById(supplierId) == null) {
        errors.add(new ValidationError("supplierId", "The supplierId does not exist"));
    }
    if (costCenterId != null && CostCenterDAO.getCostCenterById(costCenterId) == null) {
        errors.add(new ValidationError("costCenterId", "The costCenterId does not exist"));
    }
    if (requesterId != null && ActorDao.getActorById(requesterId) == null) {
        errors.add(new ValidationError("requesterId", "The requesterId does not exist"));
    }
    if (shipmentTypeId != null && PurchaseOrderDAO.getPurchaseOrderLineShipmentStatutsTypeById(shipmentTypeId) == null) {
        errors.add(new ValidationError("shipmentTypeId", "The shipmentTypeId does not exist"));
    }
    // TODO
    return errors.isEmpty() ? null : errors;

}
 
開發者ID:theAgileFactory,項目名稱:maf-desktop-app,代碼行數:26,代碼來源:PurchaseOrderLineItemRequest.java

示例14: validate

import play.data.validation.ValidationError; //導入依賴的package包/類
/**
 * Form validator.
 */
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList<>();

    if (managerId != null && ActorDao.getActorById(managerId) == null) {
        errors.add(new ValidationError("managerId", "The manager does not exist"));
    }
    if (sponsoringUnitId != null && OrgUnitDao.getOrgUnitById(sponsoringUnitId) == null) {
        errors.add(new ValidationError("sponsoringUnitId", "The sponsoringUnit does not exist"));
    }
    if (deliveryUnitId != null && OrgUnitDao.getOrgUnitById(deliveryUnitId) == null) {
        errors.add(new ValidationError("deliveryUnitId", "The deliveryUnit does not exist"));
    }
    if (portfolioId != null && PortfolioDao.getPortfolioById(portfolioId) == null) {
        errors.add(new ValidationError("portfolioId", "The portfolio does not exist"));
    }
    if (portfolioEntryTypeId != null && PortfolioEntryDao.getPETypeById(portfolioEntryTypeId) == null) {
        errors.add(new ValidationError("portfolioEntryTypeId", "The portfolioEntryType does not exist"));
    }

    return errors.isEmpty() ? null : errors;
}
 
開發者ID:theAgileFactory,項目名稱:maf-desktop-app,代碼行數:25,代碼來源:PortfolioEntryListRequest.java

示例15: validate

import play.data.validation.ValidationError; //導入依賴的package包/類
/**
 * Form validator.
 */
public List<ValidationError> validate() {
    List<ValidationError> errors = new ArrayList<>();

    if (managerId != null && ActorDao.getActorById(managerId) == null) {
        errors.add(new ValidationError("managerId", "The manager does not exist"));
    }
    if (portfolioEntryId != null && PortfolioEntryDao.getPEById(portfolioEntryId) == null) {
        errors.add(new ValidationError("portfolioEntryId", "The portfolioEntry does not exist"));
    }
    if (portfolioTypeId != null && PortfolioDao.getPortfolioTypeById(portfolioTypeId) == null) {
        errors.add(new ValidationError("portfolioTypeId", "The portfolioType does not exist"));
    }

    return errors.isEmpty() ? null : errors;
}
 
開發者ID:theAgileFactory,項目名稱:maf-desktop-app,代碼行數:19,代碼來源:PortfolioListRequest.java


注:本文中的play.data.validation.ValidationError類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。