@Test public void testLengthConstraintHandleAnyObject() { assertTrue(minMax.validate(new Object() { @Override public String toString() { return INNER; } })); assertFalse(minMax.validate(new Object() { @Override public String toString() { return GREATER; } })); }
@Override public boolean validate(Object object) { if (object == null) { return true; } int len = object.toString().length(); if (min != null && len < min) { return false; } if (max != null && len > max) { return false; } return true; }
LengthConstraint extends AbstractConstraint { @Override public boolean validate(Object object) { if (object == null) { return true; } int len = object.toString().length(); if (min != null && len < min) { return false; } if (max != null && len > max) { return false; } return true; } }
LengthConstraint extends AbstractConstraint { @Override public boolean validate(Object object) { if (object == null) { return true; } int len = object.toString().length(); if (min != null && len < min) { return false; } if (max != null && len > max) { return false; } return true; } LengthConstraint(Object min, Object max); }
LengthConstraint extends AbstractConstraint { @Override public boolean validate(Object object) { if (object == null) { return true; } int len = object.toString().length(); if (min != null && len < min) { return false; } if (max != null && len > max) { return false; } return true; } LengthConstraint(Object min, Object max); @Override boolean validate(Object object); @Override Description getDescription(); Long getMin(); Long getMax(); @Override String getErrorMessage(Object invalidValue, Locale locale); @Override int hashCode(); @Override boolean equals(Object obj); }
LengthConstraint extends AbstractConstraint { @Override public boolean validate(Object object) { if (object == null) { return true; } int len = object.toString().length(); if (min != null && len < min) { return false; } if (max != null && len > max) { return false; } return true; } LengthConstraint(Object min, Object max); @Override boolean validate(Object object); @Override Description getDescription(); Long getMin(); Long getMax(); @Override String getErrorMessage(Object invalidValue, Locale locale); @Override int hashCode(); @Override boolean equals(Object obj);  }