Skip to content

Add a Dart runtime for Protovalidate#509

Closed
SpencerC wants to merge 1 commit into
bufbuild:mainfrom
SpencerC:feature/dart-protovalidate-runtime
Closed

Add a Dart runtime for Protovalidate#509
SpencerC wants to merge 1 commit into
bufbuild:mainfrom
SpencerC:feature/dart-protovalidate-runtime

Conversation

@SpencerC

@SpencerC SpencerC commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Adds a first Dart implementation of Protovalidate (see #148).

Approach

Reflective, descriptor-driven runtime that mirrors the Go/Python/ES design: rules and structure are read from a FileDescriptorSet (with the buf.validate extensions registered), and field values are read from generated messages via reflection. The same core powers both the Validator API and the conformance executor. Because Dart has no dynamicpb, the executor unpacks each Any using a generated registry of the conformance case types.

Scope

Implements the standard, CEL-free subset of Protovalidate:

  • scalars — const / lt / lte / gt / gte / in / not_in / finite, including combined ranges (gt_lt, gte_lte_exclusive, …)
  • string (including email / uri / uuid), bytes, bool, enum
  • repeated and map, including items / keys / values
  • required / ignore and nested-message recursion

Out of scope for now (full parity would require a Dart CEL evaluator): custom / predefined / message-level CEL rules, well-known-type rules, additional string/bytes formats (hostname, ip*, address, uri_ref, tuuid, ulid, host_and_port, …), and some Protobuf Editions cases (a few of which protoc-gen-dart does not yet generate). These are enumerated in dart/conformance/expected_failures.yaml.

Conformance

Passes every in-subset case with no unexpected failures:

make conformance-dart
PASS (failed: 0, skipped: 778, passed: 2094, total: 2872)

(The 778 "skipped" are the out-of-subset cases listed in expected_failures.yaml.)

What's included

  • dart/ — the protovalidate package, conformance executor, unit tests, and README
  • Makefiletest-dart, conformance-dart, generate-dart

Notes for maintainers

  • Kept in-repo under dart/ for now so it can reuse the conformance harness; happy to extract to a protovalidate-dart repo if that's preferred.
  • No CI wiring added yet — a dart job running make test-dart + make conformance-dart can be added on request.
  • Opening as a draft: feedback welcome on the architecture and the subset scope before further polish.

🤖 Generated with Claude Code

Adds a first Dart implementation of Protovalidate under `dart/`.

The runtime is reflective and descriptor-driven: rules and structure are read
from a FileDescriptorSet (with the buf.validate extensions registered) and
field values are read from generated messages via reflection. The same core
powers the conformance executor. It implements the standard, CEL-free subset of
Protovalidate — scalars, string (incl. email/uri/uuid), bytes, enum, repeated,
and map rules, plus required/ignore and nested-message recursion. Custom CEL,
well-known-type rules, extra string/bytes formats, message-level rules, and
some Protobuf Editions cases are out of scope and recorded in
dart/conformance/expected_failures.yaml.

Conformance: passes all 2094 in-subset cases with 0 unexpected failures
(778 out-of-subset cases marked as expected failures).

- dart/: the `protovalidate` package, conformance executor, and unit tests
- Makefile: test-dart, conformance-dart, generate-dart

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@SpencerC
SpencerC force-pushed the feature/dart-protovalidate-runtime branch from 1237e4c to e123fbe Compare July 21, 2026 00:58
@SpencerC SpencerC closed this Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant