org.hibernate.validator.constraints.Email Java Examples

The following examples show how to use org.hibernate.validator.constraints.Email. 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: UserResource.java    From onedev with MIT License 7 votes vote down vote up
@ValidQueryParams
@GET
public Response query(@QueryParam("name") String name, @Email @QueryParam("email") String email, 
		@QueryParam("offset") Integer offset, @QueryParam("count") Integer count, @Context UriInfo uriInfo) {
   	if (!SecurityUtils.isAdministrator())
   		throw new UnauthorizedException("Unauthorized access to user profiles");
   	
   	EntityCriteria<User> criteria = EntityCriteria.of(User.class);
   	if (name != null)
   		criteria.add(Restrictions.eq("name", name));
	if (email != null)
		criteria.add(Restrictions.eq("email", email));
	
   	if (offset == null)
   		offset = 0;
   	
   	if (count == null || count > RestConstants.PAGE_SIZE) 
   		count = RestConstants.PAGE_SIZE;

   	Collection<User> users = userManager.query(criteria, offset, count);
	
	return Response.ok(users, RestConstants.JSON_UTF8).build();
}
 
Example #2
Source File: NotificationWebController.java    From pacbot with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "Subscribe Weekly Status Email")
@RequestMapping(value = "/subscribe", method = RequestMethod.GET)
public String subscribe(Model model, @Email @Valid @RequestParam(value = "email", required = true) String email) {
	model.addAttribute("email", email);
	Map<String, Object> response = notificationService.subscribeDigestMail(email.toLowerCase());
	model.addAttribute("model", response);
	return "subscribe";
}
 
Example #3
Source File: NotificationWebController.java    From pacbot with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "Un Subscribe Weekly Status Email")
@RequestMapping(value = "/un-subscribe", method = RequestMethod.GET)
public String unSubscribe(Model model, @Email @Valid @RequestParam(value = "email", required = true) String email) {
	model.addAttribute("email", email);
	Map<String, Object> response = notificationService.unsubscribeDigestMail(email.toLowerCase());
	model.addAttribute("model", response);
	return "un-subscribe";
}
 
Example #4
Source File: ValidationDetectionTest.java    From wisdom with Apache License 2.0 5 votes vote down vote up
@Test
public void testValidationRequiredWithSeveralParameters() {
    FakeController controller = new FakeController() {
        @Route(method = HttpMethod.GET, uri = "/")
        public Result index(@NotNull @Parameter("name") String name, @Email @NotNull @Parameter("email") String
                email, @Parameter("i") int i) {
            return ok();
        }
    };

    router.bindController(controller);

    final org.wisdom.api.router.Route route = router.getRouteFor(HttpMethod.GET, "/");
    assertThat(route).isNotNull();
    // Valid invocation
    Action.ActionResult result = action(new Invocation() {
        @Override
        public Result invoke() throws Throwable {
            return route.invoke();

        }
    }).parameter("name", "wisdom").parameter("email", "[email protected]").parameter("i", 0).invoke();

    assertThat(result.getResult().getStatusCode()).isEqualTo(Status.OK);

    // Invalid invocation
    result = action(new Invocation() {
        @Override
        public Result invoke() throws Throwable {
            return route.invoke();
        }
    }).parameter("email", "[email protected]").parameter("i", 0).invoke();

    assertThat(result.getResult().getStatusCode()).isEqualTo(Status.BAD_REQUEST);

}
 
Example #5
Source File: MessageService.java    From holdmail with Apache License 2.0 5 votes vote down vote up
public MessageList findMessages(@Null @Email String recipientEmail, Pageable pageRequest) {

        List<MessageEntity> entities;

        if (StringUtils.isBlank(recipientEmail)) {
            entities = messageRepository.findAllByOrderByReceivedDateDesc(pageRequest);
        }
        else {
            entities = messageRepository.findAllForRecipientOrderByReceivedDateDesc(recipientEmail, pageRequest);
        }

        return messageListMapper.toMessageList(entities);
    }
 
Example #6
Source File: MessageController.java    From holdmail with Apache License 2.0 5 votes vote down vote up
@RequestMapping()
public MessageList getMessages(
        @RequestParam(name = "recipient", required = false) @Email String recipientEmail,
        Pageable pageRequest) {

    return messageService.findMessages(recipientEmail, pageRequest);
}
 
Example #7
Source File: User.java    From website with GNU Affero General Public License v3.0 5 votes vote down vote up
@NotEmpty
@Size(min = 2, max = 255)
@Email
@Column(nullable = false)
public String getEmail() {
	return email;
}
 
Example #8
Source File: User.java    From spring-mvc-angular-js-hibernate-bootstrap-java-single-page-jwt-auth-rest-api-webapp-framework with MIT License 4 votes vote down vote up
@Column @Email @NotNull @NotBlank
public String getEmail() {
    return this.email;
}
 
Example #9
Source File: MethodValidatorTest.java    From vraptor4 with Apache License 2.0 4 votes vote down vote up
public void withConstraint(@Min(10) @Email String email) {
}
 
Example #10
Source File: User.java    From SpringCloud with Apache License 2.0 4 votes vote down vote up
@Email(message = "邮件格式不正确")
public String getEmail() {
    return email;
}
 
Example #11
Source File: User.java    From Mario with Apache License 2.0 4 votes vote down vote up
@Email
public String getEmail() {
    return email;
}
 
Example #12
Source File: ContactMessage.java    From website with GNU Affero General Public License v3.0 4 votes vote down vote up
@NotEmpty
@Email
@Size(max = 255)
public String getEmail() {
	return email;
}
 
Example #13
Source File: SuggestBook.java    From website with GNU Affero General Public License v3.0 4 votes vote down vote up
@NotEmpty
@Email
@Size(max = 255)
public String getEmail() {
	return email;
}
 
Example #14
Source File: EndUserRegistrationData.java    From omh-dsu-ri with Apache License 2.0 4 votes vote down vote up
@Email
public String getEmailAddress() {
    return emailAddress;
}
 
Example #15
Source File: User.java    From dubai with MIT License 4 votes vote down vote up
@NotBlank
@Email
public String getEmail() {
    return email;
}
 
Example #16
Source File: ValidationDetectionTest.java    From wisdom with Apache License 2.0 4 votes vote down vote up
@Test
public void testValidationRequiredWithOneParameterWithHibernateConstraint() {
    FakeController controller = new FakeController() {
        @Route(method = HttpMethod.GET, uri = "/")
        public Result index(@Parameter("name") @NotNull @Email String name) {
            return ok();
        }
    };

    router.bindController(controller);

    final org.wisdom.api.router.Route route = router.getRouteFor(HttpMethod.GET, "/");
    assertThat(route).isNotNull();
    assertThat(route.getArguments()).hasSize(1);
    assertThat(route.getArguments().get(0).getName()).isEqualToIgnoringCase("name");
    assertThat(route.getArguments().get(0).getSource()).isEqualTo(Source.PARAMETER);
    assertThat(route.getArguments().get(0).getRawType()).isEqualTo(String.class);

    // Valid invocation
    Action.ActionResult result = action(new Invocation() {
        @Override
        public Result invoke() throws Throwable {
            return route.invoke();
        }
    }).parameter("name", "[email protected]").invoke();

    assertThat(result.getResult().getStatusCode()).isEqualTo(Status.OK);

    // Invalid invocation (no email)
    result = action(new Invocation() {
        @Override
        public Result invoke() throws Throwable {
            return route.invoke();
        }
    }).invoke();

    assertThat(result.getResult().getStatusCode()).isEqualTo(Status.BAD_REQUEST);

    // Invalid invocation (bad email)
    result = action(new Invocation() {
        @Override
        public Result invoke() throws Throwable {
            return route.invoke();
        }
    }).parameter("name", "wisdom_is_not_an_email").invoke();

    assertThat(result.getResult().getStatusCode()).isEqualTo(Status.BAD_REQUEST);

}
 
Example #17
Source File: ValidationDetectionTest.java    From wisdom with Apache License 2.0 4 votes vote down vote up
@Test
public void testValidationRequiredWithOneParameterWithOnlyHibernateConstraint() {
    FakeController controller = new FakeController() {
        @Route(method = HttpMethod.GET, uri = "/")
        public Result index(@Parameter("name") @Email String name) {
            return ok();
        }
    };

    router.bindController(controller);

    final org.wisdom.api.router.Route route = router.getRouteFor(HttpMethod.GET, "/");
    assertThat(route).isNotNull();
    assertThat(route.getArguments()).hasSize(1);
    assertThat(route.getArguments().get(0).getName()).isEqualToIgnoringCase("name");
    assertThat(route.getArguments().get(0).getSource()).isEqualTo(Source.PARAMETER);
    assertThat(route.getArguments().get(0).getRawType()).isEqualTo(String.class);

    // Valid invocation
    Action.ActionResult result = action(new Invocation() {
        @Override
        public Result invoke() throws Throwable {
            return route.invoke();
        }
    }).parameter("name", "[email protected]").invoke();

    assertThat(result.getResult().getStatusCode()).isEqualTo(Status.OK);

    // Valid invocation even without email
    result = action(new Invocation() {
        @Override
        public Result invoke() throws Throwable {
            return route.invoke();
        }
    }).invoke();

    assertThat(result.getResult().getStatusCode()).isEqualTo(Status.OK);

    // Invalid invocation (broken email)
    result = action(new Invocation() {
        @Override
        public Result invoke() throws Throwable {
            return route.invoke();
        }
    }).parameter("name", "this-is-not an email").invoke();

    assertThat(result.getResult().getStatusCode()).isEqualTo(Status.BAD_REQUEST);

    // Invalid invocation (bad email)
    result = action(new Invocation() {
        @Override
        public Result invoke() throws Throwable {
            return route.invoke();
        }
    }).parameter("name", "wisdom_is_not_an_email").invoke();

    assertThat(result.getResult().getStatusCode()).isEqualTo(Status.BAD_REQUEST);

}
 
Example #18
Source File: ValidationController.java    From wisdom with Apache License 2.0 4 votes vote down vote up
@Route(method = HttpMethod.GET, uri = "/validation/auto")
public Result automatic(@Parameter("email") @NotNull @Email String email) {
    return ok(email);
}
 
Example #19
Source File: UserDto.java    From wetech-cms with MIT License 4 votes vote down vote up
@Email(message="邮件格式不正确")
public String getEmail() {
	return email;
}
 
Example #20
Source File: User.java    From wetech-cms with MIT License 4 votes vote down vote up
@Email(message="邮件格式不正确")
public String getEmail() {
	return email;
}
 
Example #21
Source File: User.java    From celerio-angular-quickstart with Apache License 2.0 4 votes vote down vote up
@Email
@Size(max = 100)
@Column(name = "EMAIL", length = 100)
public String getEmail() {
    return email;
}
 
Example #22
Source File: Author.java    From celerio-angular-quickstart with Apache License 2.0 4 votes vote down vote up
@Email
@Size(max = 100)
@Column(name = "EMAIL", length = 100)
public String getEmail() {
    return email;
}
 
Example #23
Source File: Guestbook.java    From Shop-for-JavaWeb with MIT License 4 votes vote down vote up
@Email @Length(min=0, max=100)
public String getEmail() {
	return email;
}
 
Example #24
Source File: User.java    From Shop-for-JavaWeb with MIT License 4 votes vote down vote up
@Email(message="邮箱格式不正确")
@Length(min=0, max=200, message="邮箱长度必须介于 1 和 200 之间")
@ExcelField(title="邮箱", align=1, sort=50)
public String getEmail() {
	return email;
}
 
Example #25
Source File: EmailStrategy.java    From hsweb-framework with Apache License 2.0 4 votes vote down vote up
@Override
protected Class<Email> getAnnotationType() {
    return Email.class;
}
 
Example #26
Source File: MessageService.java    From holdmail with Apache License 2.0 4 votes vote down vote up
public void forwardMessage(long messageId, @NotBlank @Email String recipientEmail) {

        Message message = getMessage(messageId);
        outgoingMailSender.redirectMessage(recipientEmail, message.getRawMessage());
    }
 
Example #27
Source File: FuncionarioDto.java    From ponto-inteligente-api with MIT License 4 votes vote down vote up
@NotEmpty(message = "Email não pode ser vazio.")
@Length(min = 5, max = 200, message = "Email deve conter entre 5 e 200 caracteres.")
@Email(message="Email inválido.")
public String getEmail() {
	return email;
}
 
Example #28
Source File: CadastroPJDto.java    From ponto-inteligente-api with MIT License 4 votes vote down vote up
@NotEmpty(message = "Email não pode ser vazio.")
@Length(min = 5, max = 200, message = "Email deve conter entre 5 e 200 caracteres.")
@Email(message="Email inválido.")
public String getEmail() {
	return email;
}
 
Example #29
Source File: CadastroPFDto.java    From ponto-inteligente-api with MIT License 4 votes vote down vote up
@NotEmpty(message = "Email não pode ser vazio.")
@Length(min = 5, max = 200, message = "Email deve conter entre 5 e 200 caracteres.")
@Email(message="Email inválido.")
public String getEmail() {
	return email;
}
 
Example #30
Source File: JwtAuthenticationDto.java    From ponto-inteligente-api with MIT License 4 votes vote down vote up
@NotEmpty(message = "Email não pode ser vazio.")
@Email(message = "Email inválido.")
public String getEmail() {
	return email;
}