validate.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 "google.golang.org/protobuf/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 of the correct Go type (e.g. *descriptorpb.MessageOptions).
  27. // * len(ExtensionRangeOptions) <= len(ExtensionRanges)
  28. func validateFile(t pref.FileDescriptor) error {
  29. return nil
  30. }
  31. func validateMessage(t pref.MessageDescriptor) error {
  32. return nil
  33. }
  34. func validateExtension(t pref.ExtensionDescriptor) error {
  35. return nil
  36. }
  37. func validateEnum(t pref.EnumDescriptor) error {
  38. return nil
  39. }