Package yalp.data.validation

Examples of yalp.data.validation.Error


        Book firstBook = Book.find("byIsbn", "1").first();
        firstBook.isbn = "2";
        ValidationResult res = Validation.current().valid(firstBook);
        assertFalse(res.ok);
        assertNotNull(Validation.errors(".isbn"));
        Error error = Validation.errors(".isbn").get(0);
        assertEquals("Must be unique", error.message());
    }
View Full Code Here


        Book firstBook = Book.find("byIsbn", "1").first();
        firstBook.author = bob;
        ValidationResult res = Validation.current().valid(firstBook);
        assertFalse(res.ok);
        assertNotNull(Validation.errors(".title"));
        Error error = Validation.errors(".title").get(0);
        assertEquals("Must be unique", error.message());

        Validation.clear();
        firstBook.title = "Bobs Book";
        res = Validation.current().valid(firstBook);
        assertTrue(res.ok);
View Full Code Here

    public static void _error(Map<?, ?> args, Closure body, PrintWriter out, ExecutableTemplate template, int fromLine) {
        if (args.get("arg") == null && args.get("key") == null) {
            throw new TemplateExecutionException(template.template, fromLine, "Please specify the error key", new TagInternalException("Please specify the error key"));
        }
        String key = args.get("arg") == null ? args.get("key") + "" : args.get("arg") + "";
        Error error = Validation.error(key);
        if (error != null) {
            if (args.get("field") == null) {
                out.print(error.message());
            } else {
                out.print(error.message(args.get("field") + ""));
            }
        }
    }
View Full Code Here

        testModel.setVersion(Long.valueOf(1));
        Validation.clear();
        result = Validation.current().valid(testModel);
        assertFalse(result.ok);
        assertNotNull(Validation.errors(".version"));
        Error error = Validation.errors(".version").get(0);
        System.out.println(error.getKey());
        assertEquals("The object was changed. Your version is 1 the database version is 2. " +
                "Reload and do your changes again.", error.message());      
    }
View Full Code Here

TOP

Related Classes of yalp.data.validation.Error

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.