cnabio / cnab-go

A Go implementation of CNAB Core 1.0
MIT License
69 stars 37 forks source link

Properly handle optional credentials #109

Closed jeremyrickard closed 5 years ago

jeremyrickard commented 5 years ago

A credential has a required flag, which defaults to true. As #108 and the spec point out:

required indicates whether this credential MUST be supplied. By default it is false, which means the credential is optional. When true, a runtime MUST fail if the credential is not provided.

However, we were ALWAYS requiring any credential to have a value provided. This check occurred both in the CredentialSet Validate(..) method for that is used for stateful actions, but also the Expand(...) method. The Expand(..) method had an argument to flag an call to the method as stateless, in which case we allowed a credential to not be present but we still failed on optional for stateful calls.

This PR adds explicit handling for optional credentials.

Fixes #108

glyn commented 5 years ago

A credential has a required flag, which defaults to true

Did you mean false?