Java Code Examples for org.hibernate.validator.constraints.Range

The following are top voted examples for showing how to use org.hibernate.validator.constraints.Range. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: crud-admin-spring-boot-starter   File: CrudAdminObjectField.java   View source code 6 votes vote down vote up
private void checkNumberInputType(Field field) {
	if("number".equals(type)){
		Min min = field.getAnnotation(Min.class);
		if(min != null){
			this.min = min.value();
		}
		Max max = field.getAnnotation(Max.class);
		if(max != null){
			this.max = max.value();
		}
		Range range = field.getAnnotation(Range.class);
		if(range != null){
			this.min = range.min();
			this.max = range.max();
		}
	}
}
 
Example 2
Project: spring-rest-commons-options   File: ValidatorFactory.java   View source code 6 votes vote down vote up
private static Optional<Validator> getValidator(Annotation annotation) {
	Validator validator = null;

	if (isValidable(annotation)) {
		if (annotation instanceof Range || annotation instanceof Length) {
			validator = new RangeValidator(annotation);
		} else if (annotation instanceof Pattern) {
			validator = new PatternValidator(annotation);
		} else {
			validator = new DefaultValidator(annotation);
		}
	}
	return Optional.ofNullable(validator);
}
 
Example 3
Project: rebase-server   File: FeedResource.java   View source code 6 votes vote down vote up
@GET @Produces(MediaType.APPLICATION_JSON)
public Response readAll(
    @NotEmptyButNull @QueryParam("last_id") String lastId,
    @Range(min = 1, max = Globals.MAX_SIZE) @DefaultValue("20") @QueryParam("size") int size) {

    RebaseAsserts.existCategory(category);
    List<Document> feeds = new ArrayList<>();
    List<Bson> filters = new ArrayList<>();
    if (lastId != null) {
        filters.add(lt(Feed._ID, objectId(lastId)));
    }
    filters.add(eq(Feed.CATEGORY, category));
    filters.add(eq(Feed.OWNER, owner));
    MongoDBs.feeds().find().sort(descending(Feed._ID))
        .filter(and(filters))
        .limit(size)
        .into(feeds);
    return Response.ok(feeds).build();
}
 
Example 4
Project: nest-old   File: TestObject.java   View source code 6 votes vote down vote up
@Test
public void testRange() {
	Set<ConstraintViolation<ObjectWithValidation>> violations = validator.validate(obj, Range.class);
	assertNotNull(violations);
	assertEquals(violations.size(), 1);

	if (runPeformance) {
		long time = System.currentTimeMillis();
		for (int index = 0; index < 10000; index++) {
			validator.validate(obj, Range.class);
		}
		long used = System.currentTimeMillis() - time;
		System.out.println("Hibernate Validator [Range] check used " + used + "ms, avg. " + ((double) used) / 10000
				+ "ms.");
	}
}
 
Example 5
Project: WebBoxter   File: QuestionEntity.java   View source code 5 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "QUESTION_ID_SEQ")
@SequenceGenerator(name = "QUESTION_ID_SEQ", sequenceName = "QUESTION_ID_SEQ")
@Range(min = 1l, max = 999999999l, message = RANGE)
@Column(name = "ID")
public Integer getId() {
    return id;
}
 
Example 6
Project: WebBoxter   File: AnswerEntity.java   View source code 5 votes vote down vote up
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ANSWER_ID_SEQ")
@SequenceGenerator(name = "ANSWER_ID_SEQ", sequenceName = "ANSWER_ID_SEQ")
@Range(min = 1l, max = 999999999l, message = RANGE)
@Column(name = "ID", unique = true, length = 9)
public Integer getId() {
    return id;
}
 
Example 7
Project: mqtt   File: MqttSinkProperties.java   View source code 4 votes vote down vote up
@Range(min = 0, max = 2)
public int getQos() {
	return this.qos;
}
 
Example 8
Project: spring-cloud-stream-binder-rabbit   File: RabbitCommonProperties.java   View source code 4 votes vote down vote up
@Range(min = 0, max = 255)
public Integer getMaxPriority() {
	return this.maxPriority;
}
 
Example 9
Project: cassandra   File: CassandraProperties.java   View source code 4 votes vote down vote up
@Range(min = 0, max = 65535)
public int getPort() {
	return this.port;
}
 
Example 10
Project: spring-cloud-stream-app-starters   File: SftpSessionFactoryProperties.java   View source code 4 votes vote down vote up
@Range(min = 0, max = 65535)
public int getPort() {
	return this.port;
}
 
Example 11
Project: spring-cloud-stream-app-starters   File: FtpSessionFactoryProperties.java   View source code 4 votes vote down vote up
@Range(min = 0, max = 65535)
public int getPort() {
	return this.port;
}
 
Example 12
Project: spring-cloud-stream-app-starters   File: CassandraProperties.java   View source code 4 votes vote down vote up
@Range(min = 0, max = 65535)
public int getPort() {
	return this.port;
}
 
Example 13
Project: coner-core   File: RunHibernateEntity.java   View source code 4 votes vote down vote up
@Column(nullable = false)
@Range(min = 1)
public int getSequence() {
    return sequence;
}
 
Example 14
Project: omr   File: VeiculoVO.java   View source code 4 votes vote down vote up
@Range(min = 2, max = 5)
public Integer getPorta() {
	return porta;
}
 
Example 15
Project: nest-old   File: Worker.java   View source code 4 votes vote down vote up
/**
 * @return the age
 */
@Range(min = 10)
public int getAge() {
	return age;
}
 
Example 16
Project: coner-core   File: RunHibernateEntity.java   View source code 4 votes vote down vote up
@Column(nullable = false)
@Range(min = 1)
public int getSequence() {
    return sequence;
}
 
Example 17
Project: cm_ext   File: ParcelDescriptor.java   View source code 4 votes vote down vote up
@NotNull
@Range(min = 1, max = 1)
Integer getSchema_version();
 
Example 18
Project: cm_ext   File: MemoryParameter.java   View source code 2 votes vote down vote up
/**
 * During autoconfiguration for RM, the share dictates the percentage of the
 * role's overall memory allotment that should be set aside for this memory
 * quantity.
 * <p>
 * If null, parameter is not autoconfigured for RM.
 */
@Range(min = 0, max = 100)
Integer getAutoConfigShare();