Field

info.fingo.spata.Record.Field
final class Field[A]

Intermediary to delegate parsing to in order to infer type of formatter used by parser. Provides exception-free parsing method.

Type parameters

A

target type for parsing

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def apply[B](key: String, fmt: B)(using parser: FormattedStringParser[A, B]): Decoded[A]

Safely parses string to desired type based on provided format.

Safely parses string to desired type based on provided format.

If wrong header key is provided this function will return Left[error.HeaderError,?]. If parsing fails Left[error.DataError,?] will be returned.

Type parameters

B

type of formatter

Value parameters

fmt

formatter specific for particular result type, e.g. DateTimeFormatter for dates and times

key

the name of retrieved field

parser

the parser for specific target type

Attributes

Returns

either parsed value or an error

def apply[B](idx: Int, fmt: B)(using parser: FormattedStringParser[A, B]): Decoded[A]

Safely parses string to desired type based on provided format.

Safely parses string to desired type based on provided format.

If wrong index is provided this function will return Left[error.IndexError,?]. If parsing fails Left[error.DataError,?] will be returned.

Type parameters

B

type of formatter

Value parameters

fmt

formatter specific for particular result type, e.g. DateTimeFormatter for dates and times

idx

the index of retrieved field

parser

the parser for specific target type

Attributes

Returns

either parsed value or an error