lift/framework — pull request #1183 by davewhittaker (2012-11-02 21:43:23+00:00)
Title: Some Record fields don't work when optional_? = false

Based on the thread https://groups.google.com/d/msg/liftweb/jo3xkhu2Fjs/lKV4Cdzgy9EJ

There is a bug in some Record field classes by which the setFromString method does not handle the empty string when the
field is optional.

Fields with the bug:
* DoubleTypedField
* DecimalTypedField
* LongTypedField
* BooleanTypedField

Fields without the bug (if it's not here, I didn't check it):
* BinaryTypedField
* DateTimeTypedField
* IntTypedField

EmailTypedField might also have a similar bug (I think) since the validateEmail() doesn't include the empty string as valid when the field is empty.

To correct this bug the following (or equivalent) code can be used:

def setFromString(s: String): Box[Double] = s match {
case "" if optional_? => setBox(Empty)
case _ =>setBox(tryo(java.lang.Double.parseDouble(s)))
}