Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Some Record fields don't work when optional_? = false #1183

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
4 participants

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)))
}
Owner

dpp commented Jan 11, 2012

Pointed to David W

@ghost ghost assigned davewhittaker Mar 1, 2012

All Fields now handle setFromString(null|"") by setting valueBox to E…
…mpty if the field is optional, or Failure if it is not
Owner

fmpwizard commented Nov 8, 2012

+1

Owner

davewhittaker commented Nov 8, 2012

Merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment