javax.validation.constraints.AssertFalse Java Examples

The following examples show how to use javax.validation.constraints.AssertFalse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ValidationUtils.java    From para with Apache License 2.0 6 votes vote down vote up
private static boolean isValidSimpleConstraint(String cName, String field, Object actual, LinkedList<String> err) {
	if ("required".equals(cName) && !required().isValid(actual)) {
		err.add(Utils.formatMessage("{0} is required.", field));
		return false;
	} else if (matches(AssertFalse.class, cName) && !falsy().isValid(actual)) {
		err.add(Utils.formatMessage("{0} must be false.", field));
		return false;
	} else if (matches(AssertTrue.class, cName) && !truthy().isValid(actual)) {
		err.add(Utils.formatMessage("{0} must be true.", field));
		return false;
	} else if (matches(Future.class, cName) && !future().isValid(actual)) {
		err.add(Utils.formatMessage("{0} must be in the future.", field));
		return false;
	} else if (matches(Past.class, cName) && !past().isValid(actual)) {
		err.add(Utils.formatMessage("{0} must be in the past.", field));
		return false;
	} else if (matches(URL.class, cName) && !url().isValid(actual)) {
		err.add(Utils.formatMessage("{0} is not a valid URL.", field));
		return false;
	} else if (matches(Email.class, cName) && !email().isValid(actual)) {
		err.add(Utils.formatMessage("{0} is not a valid email.", field));
		return false;
	}
	return true;
}
 
Example #2
Source File: AssertFalsePostProcessor.java    From RestDoc with Apache License 2.0 5 votes vote down vote up
@Override
public PropertyModel postProcessInternal(PropertyModel propertyModel) {
    AssertFalse assertFalseAnno = propertyModel.getPropertyItem().getAnnotation(AssertFalse.class);
    if (assertFalseAnno == null) return propertyModel;

    propertyModel.setDescription(TextUtils.combine(propertyModel.getDescription(), " (值只能为false)"));

    return propertyModel;
}
 
Example #3
Source File: ReflectionMagicWorksTest.java    From backstopper with Apache License 2.0 5 votes vote down vote up
/**
 * Makes sure that the Reflections helper stuff is working properly and capturing all annotation possibilities (class type, constructor, constructor param, method, method param, and field).
 */
@Test
public void verifyThatTheReflectionsConfigurationIsCapturingAllAnnotationPossibilities() {
    List<Pair<Annotation, AnnotatedElement>> annotationOptionsClassAnnotations = getSubAnnotationListForElementsOfOwnerClass(TROLLER.allConstraintAnnotationsMasterList,
            DifferentValidationAnnotationOptions.class);
    assertThat(annotationOptionsClassAnnotations.size(), is(10));
    assertThat(getSubAnnotationListForAnnotationsOfClassType(annotationOptionsClassAnnotations, SomeClassLevelJsr303Annotation.class).size(), is(2));
    assertThat(getSubAnnotationListForAnnotationsOfClassType(annotationOptionsClassAnnotations, OtherClassLevelJsr303Annotation.class).size(), is(1));
    assertThat(getSubAnnotationListForAnnotationsOfClassType(annotationOptionsClassAnnotations, AssertTrue.class).size(), is(1));
    assertThat(getSubAnnotationListForAnnotationsOfClassType(annotationOptionsClassAnnotations, AssertFalse.class).size(), is(1));
    assertThat(getSubAnnotationListForAnnotationsOfClassType(annotationOptionsClassAnnotations, NotNull.class).size(), is(2));
    assertThat(getSubAnnotationListForAnnotationsOfClassType(annotationOptionsClassAnnotations, Min.class).size(), is(2));
    assertThat(getSubAnnotationListForAnnotationsOfClassType(annotationOptionsClassAnnotations, Max.class).size(), is(1));
}
 
Example #4
Source File: ReflectionMagicWorksTest.java    From backstopper with Apache License 2.0 5 votes vote down vote up
@AssertFalse(message = "I am an annotated method")
public boolean annotatedMethod(String nonAnnotatedMethodParam,
                               @Max(value = 42, message = "I am an annotated method param 1") Integer annotatedMethodParam1,
                               @Min(value = 42, message = "I am an annotated method param 2") Integer annotatedMethodParam2,
                               String alsoNotAnnotatedMethodParam) {
    return true;
}
 
Example #5
Source File: TriggerPropertiesMaxMessagesDefaultOne.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@AssertFalse
public boolean isMutuallyExclusive() {
    return this.date != null && this.cron != null && this.fixedDelay != 1;
}
 
Example #6
Source File: TriggerProperties.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@AssertFalse
boolean isMutuallyExclusive();
 
Example #7
Source File: TriggerPropertiesMaxMessagesDefaultUnlimited.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@AssertFalse
public boolean isMutuallyExclusive() {
    return this.date != null && this.cron != null && this.fixedDelay != 1;
}
 
Example #8
Source File: CassandraProperties.java    From spring-cloud-stream-app-starters with Apache License 2.0 4 votes vote down vote up
@AssertFalse(message = "both 'username' and 'password' are required or neither one")
private boolean isInvalid() {
	return StringUtils.hasText(this.username) ^ StringUtils.hasText(this.password);
}
 
Example #9
Source File: ModelCreator.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void appendFalseValidator(SourceWriter w, JField field) {
	AssertFalse falseAnnotation = field.getAnnotation(AssertFalse.class);
	if (falseAnnotation != null) {
		w.println(", new AssertFalseValidator(\"%s\")", falseAnnotation.message());
	}
}