Skip to content

Parsing Lib Integrations? #14

Description

@Jacoby6000

I think it'd be very helpful to provide integrations with json/xml/ parsing libs. Ideally we'd provide a function decoder a -> validator a b -> decoder b. This way users can transparently use checklist for validation during parsing.

Example for something like circe:

def validatingDecoder[A, B](
  handleWarnings: (WarningMessages, B) => DecodeResult[B])(
  implicit decoder: Decoder[A], validator: Validator[A, B]
): Decoder[B] = 
  decoder.emap(validator.validate(_).fold(
    handleErrors = validatorErrorToCirceError,
    handleWarnings = handleWarnings,
    handleSuccess = DecodeResult.success(_)
  ))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions