本文整理汇总了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));
}
});
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}