A service for parsing strings into the native data type using IDataTypeParser instances.

This class is available on ValidationServices.dataTypeParserService.

Hierarchy (view full)

Implements

Constructors

Accessors

Methods

  • Parse the text supplied, attempting to create another value from it that will be returned. The new value may be a different data type, whether primitive or an object that you have registered with DataTypeIdentifier. If parsing fails, return an error message instead of a value. If the text is the empty string, it is up to the parser to determine what to do (return the empty string, null, a default value of the expected type, or an error message.) The implementation should not throw an exception for a parsing error. Exceptions are permitted for configuration errors, such as a missing culture. If no parser was available, it returns an error in DataTypeResolution.

    Type Parameters

    • T

    Parameters

    • text: string
    • lookupKey: string

      A lookup key that identifies the desired parser. This is expected to come from the valueHost.parserLookupKey or if null, valueHost.dataType. If no parser is found for this, the LookupKeyFallbackService is used to find another to try.

    • cultureId: string

      Such as 'en-US' and 'en'

    Returns DataTypeResolution<T>

Generated using TypeDoc v0.25.12