コード例 #1
0
  @Test
  public void testMultiColumn() {
    Author bob = Author.find("byName", "Bob").first();
    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("validation.unique", error.message());

    Validation.clear();
    firstBook.title = "Bobs Book";
    res = Validation.current().valid(firstBook);
    assertTrue(res.ok);
  }