You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quantity constructors taking String input are not tolerant of extra whitespace at beginning or end, such that Volume("3 ml") parses correctly but Volume("3 ml ") fails. It seems this could be fixed by changing parseString(s) to parseString(s.trim) in Dimension.parse(value: Any).
I haven't tested further but probably all the parseTuple((v, u)) should be parseTuple((v, u.trim)) (or maybe the regex takes care of that).
/**
* Tries to map a string or tuple value to Quantity of this Dimension
* @param value the source string (ie, "10 kW") or tuple (ie, (10, "kW"))
* @return Try[A]
*/
protected def parse(value: Any): Try[A] = value match {
case s: String ⇒ parseString(s)
case (v: Byte, u: String) ⇒ parseTuple((v, u))
case (v: Short, u: String) ⇒ parseTuple((v, u))
case (v: Int, u: String) ⇒ parseTuple((v, u))
case (v: Long, u: String) ⇒ parseTuple((v, u))
case (v: Float, u: String) ⇒ parseTuple((v, u))
case (v: Double, u: String) ⇒ parseTuple((v, u))
case _ ⇒ Failure(QuantityParseException(s"Unable to parse $name", value.toString))
}
The text was updated successfully, but these errors were encountered:
Quantity constructors taking String input are not tolerant of extra whitespace at beginning or end, such that
Volume("3 ml")
parses correctly butVolume("3 ml ")
fails. It seems this could be fixed by changingparseString(s)
toparseString(s.trim)
in Dimension.parse(value: Any).I haven't tested further but probably all the
parseTuple((v, u))
should beparseTuple((v, u.trim))
(or maybe the regex takes care of that).The text was updated successfully, but these errors were encountered: