Use structured errors during validation

Pushed a new form with short names.  We can fix it later if it hurts


On Wed, Jul 2, 2014 at 4:06 PM, Daniel Smith <notifications@github.com>
wrote:

> In pkg/api/validation.go:
>
> > @@ -27,16 +27,37 @@ var (
> >  	supportedManifestVersions util.StringSet = util.NewStringSet("v1beta1", "v1beta2")
> >  )
> >
> > -func errInvalid(field string, value interface{}) error {
> > -	return fmt.Errorf("%s is invalid: '%v'", field, value)
> > +// Validation errors.
> > +type ValidationErrorEnum string
> > +
> > +const (
> > +	validationErrorInvalid      ValidationErrorEnum = "invalid value"
> > +	validationErrorNotSupported ValidationErrorEnum = "unsupported value"
> > +	validationErrorDuplicate    ValidationErrorEnum = "duplicate value"
>
> Not necessarily. "validationError" is a bit long for my taste but if
> there's not an alternative you like, then go ahead. I think usually in go
> people use the package name to help disambiguate, allowing shorter
> names--but our package name "api" is not really helping us much here,
> unfortunately.
>
> --
> Reply to this email directly or view it on GitHub
> <https://github.com/GoogleCloudPlatform/kubernetes/pull/343/files#r14489465>
> .
>