36373839404142
public void validate(Field field, Void constraintValue, MessageFormatter formatter, Object value) throws ValidationException { if (value == null || value.toString().equals("")) throw new ValidationException(buildMessage(formatter, field)); }
48495051525354
public void validate(Field field, Long constraintValue, MessageFormatter formatter, Number value) throws ValidationException { if (value.longValue() < constraintValue) throw new ValidationException(buildMessage(formatter, field, constraintValue)); }
3738394041424344
{ return new Long(clientValue.trim()); } catch (NumberFormatException ex) { throw new ValidationException(messages.format("integer-format-exception", clientValue)); } }
3940414243444546
{ return new Integer(clientValue.trim()); } catch (NumberFormatException ex) { throw new ValidationException(messages.format("integer-format-exception", clientValue)); } }
3637383940414243
{ return new Double(clientValue.trim()); } catch (NumberFormatException ex) { throw new ValidationException(messages.format("number-format-exception", clientValue)); } }
4647484950515253545556
// And it gets tricky because we probably should trim spaces! if (input.equalsIgnoreCase("zero")) return 0; if (input.equalsIgnoreCase("i")) throw new ValidationException("Rational numbers only, please."); // Get the default behavior. return null; }
58596061626364
void onValidateFromCount(Integer count) throws ValidationException { // count may be null if (count == null) return; if (count.equals(13)) throw new ValidationException("Thirteen is an unlucky number."); }
{ return new Float(clientValue.trim()); } catch (NumberFormatException ex) { throw new ValidationException(messages.format("number-format-exception", clientValue)); } }
4041424344454647