CaseParser

CaseParser

A parser an error cases can use to format a value extracted from an error.

Constructor

new CaseParser(name, parser)

Source:
Parameters:
Name Type Description
name string

The name of the parser.

parser Object.<string, any> | function

A function to parse a value or an object to map the value to something else.

Throws:
  • If the name is not a string.

    Type
    TypeError
  • If the parser is not a function nor an object.

    Type
    TypeError
  • If the parser is an empty object.

    Type
    Error

Members

is :CaseParserType

Source:

An object with properties to validate the parser type.

Type:

name :string

Source:

The name of the parser.

Type:

Methods

parse(value) → {*}

Source:

Parse a value with the class parser. If the parser is a map and the value is an object with a raw property, which means it comes from another map parser, instead of generating a new value, the parser will merge the new value in top of the previous one.

Parameters:
Name Type Description
value *

The value to parse.

Returns:

The result of the parsing.

Type
*