Package javango.forms.fields

Examples of javango.forms.fields.Field.clean()


    field.setName("fieldName");
    field.setRequired(false);
   
    Map<String, String> errors = new HashMap<String, String>();
   
    field.clean(new String[]{""}, errors);
    assertTrue(errors.isEmpty());
  }

  public void testInvalid() throws Exception {
    Field field = new BooleanField(injector.getInstance(WidgetFactory.class));
View Full Code Here


    Field field = new BooleanField(injector.getInstance(WidgetFactory.class));
    field.setName("fieldName");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Boolean value = (Boolean)field.clean(new String []{"qwert"}, errors);
    assertFalse(errors.isEmpty());
    assertTrue(errors.containsKey("fieldName"));
    assertEquals("Unknown value 'qwert'", errors.get("fieldName"));
  }
View Full Code Here

    Field field = new BooleanField(injector.getInstance(WidgetFactory.class));
    field.setName("fieldName");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Boolean value = (Boolean)field.clean(new String[]{"true"}, errors);
    assertTrue(errors.isEmpty());
    assertEquals(Boolean.TRUE, value);
 

  public void testValidFalse() throws Exception {
View Full Code Here

    Field field = new BooleanField(injector.getInstance(WidgetFactory.class));
    field.setName("fieldName");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Boolean value = (Boolean)field.clean(new String[]{"false"}, errors);
    assertTrue(errors.isEmpty());
    assertEquals(Boolean.FALSE, value);
 

}
View Full Code Here

    choices.put(2L, "Paul");
    Field f = (injector.getInstance(LongSelectField.class)).setChoices(choices).setName("choice_field");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    assertEquals(1L, f.clean(new String[]{"1"}, errors));
    assertTrue(errors.isEmpty());

   
    errors = new HashMap<String, String>();
    f.clean(new String[]{"John"}, errors);
View Full Code Here

    assertEquals(1L, f.clean(new String[]{"1"}, errors));
    assertTrue(errors.isEmpty());

   
    errors = new HashMap<String, String>();
    f.clean(new String[]{"John"}, errors);
    assertEquals("Select a valid choice. That choice is not one of the available choices.", errors.get("choice_field"));   
  }
 
  public void testBlankIsAnOption() throws Exception {
    Map<String, String> choices = new HashMap<String, String>();
View Full Code Here

    Field field = new IntegerField(injector.getInstance(WidgetFactory.class));
    field.setName("fieldName");

    Map<String, String> errors = new HashMap<String, String>();
   
    Long value = (Long)field.clean(new String[]{""}, errors);
    assertFalse(errors.isEmpty());
    assertTrue(errors.containsKey(field.getName()));
    assertEquals("Required", errors.get(field.getName()));
    // Integer number not valid
  }
View Full Code Here

    field.setName("fieldName");
    field.setRequired(false);
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Long value = (Long)field.clean(new String[]{""}, errors);
    assertTrue(errors.isEmpty());
  }

  public void testInvalid() throws Exception {
    Field field = new IntegerField(injector.getInstance(WidgetFactory.class));
View Full Code Here

    Field field = new IntegerField(injector.getInstance(WidgetFactory.class));
    field.setName("fieldName");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Long value = (Long)field.clean(new String[]{"qwert"}, errors);
    assertFalse(errors.isEmpty());
    assertTrue(errors.containsKey("fieldName"));
    assertEquals("Integer number not valid", errors.get("fieldName"));
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.