Parser

io.eezo.core.Parser
See theParser companion object
trait Parser[X]

How text from outside becomes a value of one Scala type, and what a missing text means for it.

It lives in core because more than forms read text. A form field and a configuration value are the same question, "is this text an Int", asked from two modules that cannot see each other, and answering it twice is how the two would come to disagree about what a number is. http's Field is composed over one of these and adds only what a browser input needs, so the reading itself has one home.

A message is shown to whoever typed the text, a form's user or an operator at boot, so it reads as a predicate about the value and never repeats the text: the text may be a secret.

Attributes

Companion
object
Source
Parser.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def read(text: String): Either[String, X]

Reads the text, or says why it will not read.

Reads the text, or says why it will not read.

Attributes

Source
Parser.scala

Concrete methods

def absent: Option[X]

The value to use when there is no text at all, if there is one.

The value to use when there is no text at all, if there is one.

A separate answer from reading the empty text, because a missing key and an empty one differ for some sources: a browser omits an unchecked checkbox entirely, and an unset variable is not one set to nothing. Only a type that has a sensible default says so, which leaves every other one able to report itself as required.

Attributes

Source
Parser.scala