Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing Lib Integrations? #14

Open
Jacoby6000 opened this issue Jan 29, 2018 · 1 comment
Open

Parsing Lib Integrations? #14

Jacoby6000 opened this issue Jan 29, 2018 · 1 comment

Comments

@Jacoby6000
Copy link
Collaborator

Jacoby6000 commented Jan 29, 2018

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(_)
  ))
@Jacoby6000
Copy link
Collaborator Author

Tighter integrations than the one above could reduce overhead a bit, but I think the above is a good first-pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant