narqo / authres

RFC 5451/7001/7601 Authentication-Results Header Parsing in Go
1 stars 1 forks source link

More parsing, softer validation? #3

Open cv711 opened 6 years ago

cv711 commented 6 years ago

The library is quite strict with validating arguments and exits when things are not exactly as it expects them to be. What would you say if we always tried to parse as much as we can and maybe append the validation errors to a collection struct that a user can optionally pass in during initialisation?

Chris

narqo commented 6 years ago

Could you add a piece of code which will illustrate the usecase? Do you want the parser to return an error that will aggregate every issue that the passed string has?

I image the following low-level API:

func ParseAuthenticationResults(rawStr) (*AuthenticationResults, error) {
  p := AuthresParser{rawStr}
  if err := p.Parse(); err != nil {
    // err is of internal type ValidationError, and contains all the separate parsing errors
  }
  return p.AuthenticationResults(), nil
}

By default, the first parsing error might be fatal, for the whole parsing process, as it's now, but the AuthresParser might have an option, which switches off such strict behaviour.

cv711 commented 6 years ago

something like #6 maybe?