private void validateMax(Double value, Model m){ if(value >= max){ m.addValidator(this, attribute); } }
private void validateMin(Double value, Model m){ if(value <= min){ m.addValidator(this, attribute); } }
private void validateIntegerOnly(Object value, Model m){ try{ Integer.valueOf(value.toString()); } catch(NumberFormatException e) { m.addValidator(this, attribute); } }
private boolean present(Object value, Model m){ if(allowNull){ return true; } if(value == null){ setMessage("value is missing"); m.addValidator(this, attribute); return false; }else{ return true; } }
@Override public void validate(Model m) { if(m.get(attribute) == null){ m.addValidator(this, attribute); return; } Object value = m.get(attribute); if (!(value instanceof String)) { throw new IllegalArgumentException("attribute " + attribute + " is not String"); } Matcher matcher = pattern.matcher((String) value); if(!matcher.matches()){ m.addValidator(this, attribute); } } }
@Override public void convert(Model m) { Object val = m.get(attributeName); if (!(val instanceof java.util.Date) && !blank(val)) { try { long time = df.parse(val.toString()).getTime(); java.sql.Date d = new java.sql.Date(time); m.set(attributeName, d); } catch (ParseException e) { m.addValidator(this, attributeName); } } }
@Override public void convert(Model m) { Object val = m.get(attributeName); if (!(val instanceof Timestamp) && !blank(val)) { try { long time = df.parse(val.toString()).getTime(); Timestamp t = new Timestamp(time); m.set(attributeName, t); } catch(ParseException e) { m.addValidator(this, attributeName); } } }
public void validate(Model m) { Object value = m.get(this.attribute); if(allowBlank && (null == value || "".equals(value))) { return; } if(null == value) { m.addValidator(this, this.attribute); return; } if(!(value instanceof String)) { throw new IllegalArgumentException("Attribute must be a String"); } else { if(!this.lengthOption.validate((String)((String)m.get(this.attribute)))) { //somewhat confusingly this adds an error for a validator. m.addValidator(this, this.attribute); } } }
@Override public void validate(Model m) { if (blank(m.get(attribute))) { //TODO: use resource bundles for messages m.addValidator(this, attribute); } }
@Override public void validate(Model m) { if(m.get(attribute) == null){ m.addValidator(this, attribute); return; Method compareTo = value.getClass().getMethod("compareTo"); if(((Integer)compareTo.invoke(value, min)) == -1 || ((Integer)compareTo.invoke(value, max)) == 1){ m.addValidator(this, attribute); Byte mx = (Byte)max; if(v > mx || v < mn) m.addValidator(this, attribute); }else if(value.getClass().equals(Double.class)){ Double v = (Double)value; Double mx = (Double)max; if(v > mx || v < mn) m.addValidator(this, attribute); }else if(value.getClass().equals(Float.class)){ Float v = (Float)value; Float mx = (Float)max; if(v > mx || v < mn) m.addValidator(this, attribute); }else if(value.getClass().equals(Integer.class)){ Integer v = (Integer)value; Integer mx = (Integer)max; if(v > mx || v < mn)
nf.parse(input, pp); if (pp.getIndex() != (input.length())) { m.addValidator(this, attribute); m.addValidator(this, attribute);
@Override public void validate(Model model) { MetaModel metaModel = metaModelOf(model.getClass()); if (new DB(metaModel.getDbName()).count(metaModel.getTableName(), attribute + " = ?", model.get(attribute)) > 0) { model.addValidator(this, attribute); } } }
private void validateMax(Double value, Model m){ if(value >= max){ m.addValidator(this, attribute); } }
private void validateMin(Double value, Model m){ if(value <= min){ m.addValidator(this, attribute); } }
private void validateMax(Double value, Model m){ if(value >= max){ m.addValidator(this, attribute); } }
private void validateIntegerOnly(Object value, Model m){ try{ Integer.valueOf(value.toString()); } catch(NumberFormatException e) { m.addValidator(this, attribute); } }
private void validateIntegerOnly(Object value, Model m){ try{ Integer.valueOf(value.toString()); } catch(NumberFormatException e) { m.addValidator(this, attribute); } }
@Override public void convert(Model m) { Object val = m.get(attributeName); if (!(val instanceof java.util.Date) && !blank(val)) { try { long time = df.parse(val.toString()).getTime(); java.sql.Date d = new java.sql.Date(time); m.set(attributeName, d); } catch (ParseException e) { m.addValidator(this, attributeName); } } }
@Override public void validate(Model m) { if (blank(m.get(attribute))) { //TODO: use resource bundles for messages m.addValidator(this, attribute); } }
@Override public void validate(Model m) { if (blank(m.get(attribute))) { //TODO: use resource bundles for messages m.addValidator(this, attribute); } }