Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/api/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (a *API) CreateNamespace(ctx context.Context, in *stencilv1beta1.CreateName
}

func (a *API) UpdateNamespace(ctx context.Context, in *stencilv1beta1.UpdateNamespaceRequest) (*stencilv1beta1.UpdateNamespaceResponse, error) {
ns, err := a.namespace.Update(ctx, domain.Namespace{ID: in.GetId(), Format: in.GetFormat().String(), Description: in.GetDescription()})
ns, err := a.namespace.Update(ctx, domain.Namespace{ID: in.GetId(), Format: in.GetFormat().String(), Compatibility: in.GetCompatibility().String(), Description: in.GetDescription()})
return &stencilv1beta1.UpdateNamespaceResponse{Namespace: namespaceToProto(ns)}, err
}

Expand Down
10 changes: 5 additions & 5 deletions server/validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func checkIfFieldRequired(f protoreflect.FieldDescriptor) bool {
return false
}

func checkValueExists(kind protoreflect.Kind, v protoreflect.Value) bool {
switch kind {
func checkValueExists(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
switch fd.Kind() {
case protoreflect.BytesKind:
d := v.Bytes()
return len(d) > 0
Expand All @@ -38,8 +38,8 @@ func checkValueExists(kind protoreflect.Kind, v protoreflect.Value) bool {
return len(d) > 0
case protoreflect.EnumKind:
d := v.Enum()
// This relies on the convention that, in enum definition 0 value is UNSPECIFIED
return d != 0
ed := fd.Enum().Values().ByNumber(d)
return ed != nil
default:
return true
}
Expand All @@ -65,7 +65,7 @@ func validateMessage(m protoreflect.ProtoMessage) []string {
prefixedFields := addPrefix(fd.JSONName(), nestedFields)
missingFields = append(missingFields, prefixedFields...)
}
if checkIfFieldRequired(fd) && !checkValueExists(fd.Kind(), v) {
if checkIfFieldRequired(fd) && !checkValueExists(fd, v) {
missingFields = append(missingFields, fd.JSONName())
}
}
Expand Down