func (meta Meta) Validate() error {
	if meta.Name == "" {
		return errors.NewNotValid(nil, "resource missing name")
	}

	var typeUnknown Type
	if meta.Type == typeUnknown {
		return errors.NewNotValid(nil, "resource missing type")
	}
	if err := meta.Type.Validate(); err != nil {
		msg := fmt.Sprintf("invalid resource type %v: %v", meta.Type, err)
		return errors.NewNotValid(nil, msg)
	}

	if meta.Type == TypeFile && meta.Path == "" {
		// TODO(ericsnow) change "filename" to "path"
		return errors.NewNotValid(nil, "resource missing filename")
	}
	if meta.Type == TypeFile {
		if strings.Contains(meta.Path, "/") {
			msg := fmt.Sprintf(`filename cannot contain "/" (got %q)`, meta.Path)
			return errors.NewNotValid(nil, msg)
		}
		// TODO(ericsnow) Constrain Path to alphanumeric?
	}

	return nil
}
// Validate checks the resource metadata to ensure the data is valid.
Validate checks the resource metadata to ensure the data is valid.
// Validate checks the resource metadata to ensure the data is valid .
func (meta Meta) Validate() error {
	if meta.Name == "" {
		return errors.NewNotValid(nil, "resource missing name")
	}
	var typeUnknown Type
	if meta.Type == typeUnknown {
		return errors.NewNotValid(nil, "resource missing type")
	}
	if err := meta.Type.Validate(); err != nil {
		msg := fmt.Sprintf("invalid resource type %v: %v", meta.Type, err)
		return errors.NewNotValid(nil, msg)
	}
	if meta.Type == TypeFile && meta.Path == "" {
		return errors.NewNotValid(nil, "resource missing filename")
	}
	if meta.Type == TypeFile {
		if strings.Contains(meta.Path, "/") {
			msg := fmt.Sprintf(`filename cannot contain "/" (got %q)`, meta.Path)
			return errors.NewNotValid(nil, msg)
		}
	}
	return nil
}
func ( meta Meta ) Validate ( ) error { if meta . Name == " " { return errors . NewNotValid ( nil , " " ) } var typeUnknown Type if meta . Type == typeUnknown { return errors . NewNotValid ( nil , " " ) } if err := meta . Type . Validate ( ) ; err != nil { msg := fmt . Sprintf ( " " , meta . Type , err ) return errors . NewNotValid ( nil , msg ) } if meta . Type == TypeFile && meta . Path == " " { return errors . NewNotValid ( nil , " " ) } if meta . Type == TypeFile { if strings . Contains ( meta . Path , " " ) { msg := fmt . Sprintf ( `filename cannot contain "/" (got %q)` , meta . Path ) return errors . NewNotValid ( nil , msg ) } } return nil }
Validate checks the resource metadata to ensure the data is valid.
Validate checks the resource metadata to ensure the data is valid .
// TODO(ericsnow) change "filename" to "path" // TODO(ericsnow) Constrain Path to alphanumeric?