本文整理汇总了Java中org.lastaflute.web.validation.Required类的典型用法代码示例。如果您正苦于以下问题:Java Required类的具体用法?Java Required怎么用?Java Required使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Required类属于org.lastaflute.web.validation包,在下文中一共展示了Required类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_signin_validationError_required
import org.lastaflute.web.validation.Required; //导入依赖的package包/类
public void test_signin_validationError_required() {
// ## Arrange ##
SigninAction action = new SigninAction();
inject(action);
SigninForm form = new SigninForm();
// ## Act ##
// ## Assert ##
assertValidationError(() -> action.signin(form)).handle(data -> {
data.requiredMessageOf("account", Required.class);
data.requiredMessageOf("password", Required.class);
TestingHtmlData htmlData = validateHtmlData(data.hookError());
htmlData.assertHtmlForward(HarborHtmlPath.path_Signin_SigninHtml);
});
}
示例2: getConstraintDescriptor
import org.lastaflute.web.validation.Required; //导入依赖的package包/类
@Required
@Override
public ConstraintDescriptor<?> getConstraintDescriptor() {
String methodName = "getConstraintDescriptor";
Method method;
try {
method = MockConstraintViolation.class.getMethod(methodName, new Class<?>[] {});
} catch (NoSuchMethodException | SecurityException e) {
throw new IllegalStateException("Failed to get the method: " + methodName, e);
}
Required annotation = method.getAnnotation(Required.class);
return new ConstraintDescriptor<Annotation>() {
@Override
public Annotation getAnnotation() {
return annotation;
}
@Override
public String getMessageTemplate() {
return null;
}
@Override
public Set<Class<?>> getGroups() {
return DfCollectionUtil.newHashSet(ClientError.class);
}
@Override
public Set<Class<? extends Payload>> getPayload() {
return null;
}
@Override
public ConstraintTarget getValidationAppliesTo() {
return null;
}
@Override
public List<Class<? extends ConstraintValidator<Annotation, ?>>> getConstraintValidatorClasses() {
return null;
}
@Override
public Map<String, Object> getAttributes() {
return null;
}
@Override
public Set<ConstraintDescriptor<?>> getComposingConstraints() {
return null;
}
@Override
public boolean isReportAsSingleViolation() {
return false;
}
@Override
public ValidateUnwrappedValue getValueUnwrapping() {
return null;
}
@Override
public <U> U unwrap(Class<U> type) {
return null;
}
};
}
示例3: doCheckMismatchedValidatorAnnotation
import org.lastaflute.web.validation.Required; //导入依赖的package包/类
protected void doCheckMismatchedValidatorAnnotation(Field field, Map<String, Class<?>> genericMap) { // recursive point
pathDeque.push(field.getName());
checkedTypeSet.add(field.getDeclaringClass());
final Class<?> fieldType = deriveFieldType(field, genericMap);
// *depends on JSON rule so difficult, check only physical mismatch here
//if (isFormPropertyCannotNotNullType(fieldType)) {
// final Class<NotNull> notNullType = NotNull.class;
// if (field.getAnnotation(notNullType) != null) {
// throwExecuteMethodFormPropertyValidationMismatchException(property, notNullType);
// }
//}
if (isCannotNotEmptyType(fieldType)) {
final Class<NotEmpty> notEmptyType = NotEmpty.class;
if (field.getAnnotation(notEmptyType) != null) {
throwExecuteMethodNotEmptyValidationMismatchException(field, notEmptyType);
}
}
if (isCannotNotBlankType(fieldType)) {
final Class<NotBlank> notBlankType = NotBlank.class;
if (field.getAnnotation(notBlankType) != null) {
throwExecuteMethodNotEmptyValidationMismatchException(field, notBlankType);
}
}
if (isFormPropertyCannotRequiredPrimitiveType(fieldType)) {
final Class<Required> requiredType = Required.class;
if (field.getAnnotation(requiredType) != null) {
throwExecuteMethodPrimitiveValidationMismatchException(field, requiredType);
}
final Class<NotNull> notNullType = NotNull.class;
if (field.getAnnotation(notNullType) != null) {
throwExecuteMethodPrimitiveValidationMismatchException(field, notNullType);
}
}
if (Collection.class.isAssignableFrom(fieldType)) { // only collection, except array and map, simply
doCheckGenericBeanValidationMismatch(field);
} else if (mayBeNestedBeanType(fieldType)) {
doCheckNestedValidationMismatch(fieldType);
doCheckGenericBeanValidationMismatch(field);
}
pathDeque.pop();
}