validate.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2018 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package prototype
  5. import (
  6. pref "github.com/golang/protobuf/v2/reflect/protoreflect"
  7. )
  8. // TODO: This is important to prevent users from creating invalid types,
  9. // but is not functionality needed now.
  10. //
  11. // Things to verify:
  12. // * Weak fields are only used if flags.Proto1Legacy is set
  13. // * Weak fields can only reference singular messages
  14. // (check if this the case for oneof fields)
  15. // * FieldDescriptor.MessageType cannot reference a remote type when the
  16. // remote name is a type within the local file.
  17. // * Default enum identifiers resolve to a declared number.
  18. // * Default values are only allowed in proto2.
  19. // * Default strings are valid UTF-8? Note that protoc does not check this.
  20. // * Field extensions are only valid in proto2, except when extending the
  21. // descriptor options.
  22. // * Remote enum and message types are actually found in imported files.
  23. // * Placeholder messages and types may only be for weak fields.
  24. // * Placeholder full names must be valid.
  25. // * The name of each descriptor must be valid.
  26. // * Options are consistent with constructor fields:
  27. // Message.IsMapEntry and Message.Options.MapEntry
  28. // Field.IsPacked and Field.Options.Packed
  29. func validateFile(t pref.FileDescriptor) error {
  30. return nil
  31. }
  32. func validateMessage(t pref.MessageDescriptor) error {
  33. return nil
  34. }
  35. func validateExtension(t pref.ExtensionDescriptor) error {
  36. return nil
  37. }
  38. func validateEnum(t pref.EnumDescriptor) error {
  39. return nil
  40. }