Package br.com.caelum.vraptor.validator

Examples of br.com.caelum.vraptor.validator.Validations


   * by VRaptor's <code>MultipartInterceptor</code>.
   */
  @Path("/dvds")
  @Post
  public void add(final Dvd dvd, UploadedFile file) {
      validator.checking(new Validations() {{
        if (dvd != null) {
          that(dvd.getTitle(), is(notEmpty()), "login", "invalid_title");
          that(dvd.getType(), is(notNullValue()), "name", "invalid_type");
          that(dvd.getDescription(), is(notEmpty()), "description", "invalid_description");
          that(dvd.getDescription().length() >= 6, "description", "invalid_description");
View Full Code Here


     */
    @Path("/users/{user.login}/dvds/{dvd.id}")
    @Put
  public void addToMyList(final User user, final Dvd dvd) {
      final User sessionUser = refreshUser();
      validator.checking(new Validations() {{
        that(user.getLogin(), is(sessionUser.getLogin()),"user", "you_cant_add_to_others_list");
        that(sessionUser.getDvds(), not(hasItem(dvd)), "dvd", "you_already_have_this_dvd");
    }});

    validator.onErrorUsePageOf(UsersController.class).home();
View Full Code Here

    final User currentUser = dao.find(login, password);

    // if no user is found, adds an error message to the validator
    // "invalid_login_or_password" is the message key from messages.properties,
    // and that key is used with the fmt taglib in index.jsp, for example: <fmt:message key="error.key">
    validator.checking(new Validations() {{
        that(currentUser, is(notNullValue()), "login", "invalid_login_or_password");
    }});
    // you can use "this" to redirect to another logic from this controller
    validator.onErrorUsePageOf(this).login();
View Full Code Here

  @Path("/users")
  @Post
  @Public
  public void add(final User user) {
//    validator.validate(user); // will add all validation errors from Hibernate Validator
      validator.checking(new Validations() {{
        // checks if there is already an user with the specified login
        boolean loginDoesNotExist = !dao.containsUserWithLogin(user.getLogin());
        that(loginDoesNotExist, "login", "login_already_exists");

        that(user.getLogin().matches("[a-z0-9_]+"), "login", "invalid_login");
View Full Code Here

            List<FileItem> fileItems = fileUploadHandler.parseRequest(request);
            logger.debug("Found {} attributes in the multipart form submission. Parsing them.", fileItems.size());

            new MultipartItemsProcessor(fileItems, request, parameters).process();
        } catch (final SizeLimitExceededException e) {
            validator.checking(new Validations() {
                {
                    that(false, "upload", "file.limit.exceeded", e.getActualSize(), e.getPermittedSize());
                }
            });
            logger.warn("The file size limit was exceeded.", e);
View Full Code Here

     * file.limit.exceeded using {@link Validations}.
     *
     * @param e
     */
    protected void reportSizeLimitExceeded(final SizeLimitExceededException e) {
        validator.checking(new Validations() {
            {
                that(false, "upload", "file.limit.exceeded", e.getActualSize(), e.getPermittedSize());
            }
        });

View Full Code Here

            List<FileItem> fileItems = fileUploadHandler.parseRequest(request);
            logger.debug("Found {} attributes in the multipart form submission. Parsing them.", fileItems.size());

            new MultipartItemsProcessor(fileItems, request, parameters).process();
        } catch (final SizeLimitExceededException e) {
            validator.checking(new Validations() {
                {
                    that(false, "upload", "file.limit.exceeded", e.getActualSize(), e.getPermittedSize());
                }
            });
            logger.warn("The file size limit was exceeded.", e);
View Full Code Here

     * file.limit.exceeded using {@link Validations}.
     *
     * @param e
     */
    protected void reportSizeLimitExceeded(final SizeLimitExceededException e) {
        validator.checking(new Validations() {
            {
                that(false, "upload", "file.limit.exceeded", e.getActualSize(), e.getPermittedSize());
            }
        });

View Full Code Here

     * maxRequestSize() attributes in a Filter.
     *
     * @param e
     */
    protected void reportSizeLimitExceeded(final IllegalStateException e) {
        validator.checking(new Validations() {
            {
                that(false, "upload", "servlet3.upload.filesize.exceeded");
            }
        });

View Full Code Here

    List<FileItem> fileItems;
    try {
      fileItems = fileUploadHandler.parseRequest(request);
    } catch (final SizeLimitExceededException e) {
      validator.checking(new Validations() {{
        that(false, "upload", "file.limit.exceeded", e.getActualSize(), e.getPermittedSize());
      }});
      logger.warn("The file size limit was exceeded.", e);
      stack.next(method, instance);
      return;
View Full Code Here

TOP

Related Classes of br.com.caelum.vraptor.validator.Validations

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.