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 Project: onedev   Author: theonedev   File: UserResource.java    License: 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 Project: pacbot   Author: tmobile   File: NotificationWebController.java    License: 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 #3
Source Project: pacbot   Author: tmobile   File: NotificationWebController.java    License: 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 #4
Source Project: holdmail   Author: SpartaSystems   File: MessageService.java    License: 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 #5
Source Project: holdmail   Author: SpartaSystems   File: MessageController.java    License: 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 #6
Source Project: website   Author: Paperight   File: User.java    License: 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 #7
Source Project: wisdom   Author: wisdom-framework   File: ValidationDetectionTest.java    License: 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 #8
Source Project: onedev   Author: theonedev   File: User.java    License: MIT License 4 votes vote down vote up
@Editable(order=300)
@NotEmpty
@Email
public String getEmail() {
	return email;
}
 
Example #9
Source Project: ponto-inteligente-api   Author: m4rciosouza   File: JwtAuthenticationDto.java    License: 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;
}
 
Example #10
Source Project: ponto-inteligente-api   Author: m4rciosouza   File: CadastroPFDto.java    License: 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 #11
Source Project: ponto-inteligente-api   Author: m4rciosouza   File: CadastroPJDto.java    License: 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 #12
Source Project: ponto-inteligente-api   Author: m4rciosouza   File: FuncionarioDto.java    License: 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 #13
Source Project: holdmail   Author: SpartaSystems   File: MessageService.java    License: 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 #14
Source Project: hsweb-framework   Author: hs-web   File: EmailStrategy.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected Class<Email> getAnnotationType() {
    return Email.class;
}
 
Example #15
Source Project: Shop-for-JavaWeb   Author: EleTeam   File: User.java    License: 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 #16
Source Project: Shop-for-JavaWeb   Author: EleTeam   File: Guestbook.java    License: MIT License 4 votes vote down vote up
@Email @Length(min=0, max=100)
public String getEmail() {
	return email;
}
 
Example #17
Source Project: celerio-angular-quickstart   Author: jaxio   File: Author.java    License: 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 #18
Source Project: celerio-angular-quickstart   Author: jaxio   File: User.java    License: 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 #19
Source Project: wetech-cms   Author: cjbi   File: User.java    License: MIT License 4 votes vote down vote up
@Email(message="邮件格式不正确")
public String getEmail() {
	return email;
}
 
Example #20
Source Project: wetech-cms   Author: cjbi   File: UserDto.java    License: MIT License 4 votes vote down vote up
@Email(message="邮件格式不正确")
public String getEmail() {
	return email;
}
 
Example #21
@Column @Email @NotNull @NotBlank
public String getEmail() {
    return this.email;
}
 
Example #22
Source Project: SpringCloud   Author: SoftwareKing   File: User.java    License: Apache License 2.0 4 votes vote down vote up
@Email(message = "邮件格式不正确")
public String getEmail() {
    return email;
}
 
Example #23
Source Project: Mario   Author: ZheYuan   File: User.java    License: Apache License 2.0 4 votes vote down vote up
@Email
public String getEmail() {
    return email;
}
 
Example #24
Source Project: website   Author: Paperight   File: ContactMessage.java    License: GNU Affero General Public License v3.0 4 votes vote down vote up
@NotEmpty
@Email
@Size(max = 255)
public String getEmail() {
	return email;
}
 
Example #25
Source Project: website   Author: Paperight   File: SuggestBook.java    License: GNU Affero General Public License v3.0 4 votes vote down vote up
@NotEmpty
@Email
@Size(max = 255)
public String getEmail() {
	return email;
}
 
Example #26
Source Project: omh-dsu-ri   Author: openmhealth   File: EndUserRegistrationData.java    License: Apache License 2.0 4 votes vote down vote up
@Email
public String getEmailAddress() {
    return emailAddress;
}
 
Example #27
Source Project: dubai   Author: guuuuo   File: User.java    License: MIT License 4 votes vote down vote up
@NotBlank
@Email
public String getEmail() {
    return email;
}
 
Example #28
Source Project: wisdom   Author: wisdom-framework   File: ValidationDetectionTest.java    License: 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 #29
Source Project: wisdom   Author: wisdom-framework   File: ValidationDetectionTest.java    License: 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 #30
Source Project: wisdom   Author: wisdom-framework   File: ValidationController.java    License: 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);
}