Skip to content

Releases: bufbuild/protovalidate-python

v0.12.0

18 Jun 19:27
3cfbfb3
Compare
Choose a tag to compare

Breaking Changes

New API for creating a validator and running validation.

Users can now specify a Config object when explicitly creating a validator, allowing for configuring validation logic. Currently, the two available options are:

fail_fast (bool): If True, validation stops after the first failure.
regex_matches_func (Callable[[str, str], bool): An optional function for overriding this library's matches logic for regular expressions.

Example:

from protovalidate import Config, Validator

cfg = Config(fail_fast=True)
validator = protovalidate.Validator(config=cfg)

validator.validate(msg)

As a result of the above, we have removed the fail_fast parameter from the validate and collect_violations methods on a validator. Users should instead use the above config approach.

Flagging invalid re2 syntax

Usage of invalid re2 syntax will now throw an evaluation error. While the CEL spec specifies that regular expressions should follow the re2 syntax, the underlying regex engine in protovalidate-python is still Python's re package. This is because there is currently no pre-built binary that supports Python 3.13 (issue).

So, to get as close as possible until then, we are flagging invalid re2 syntax used in regular expressions. Users can also choose to override this and bring their own re2 engine by using the config approach above.

What's Changed

  • Add ability to specify custom regex matcher by @smaye81 in #325
  • Add the ability to specify a config to validators by @smaye81 in #323
  • Implement matches override by @smaye81 in #319

This release is compatible with protovalidate v0.13.3.

Full Changelog: v0.11.0...v0.12.0

v0.11.0

13 Jun 16:02
e88b0da
Compare
Choose a tag to compare

What's Changed

This release is compatible with protovalidate v1.0.0-rc.4.

New Contributors

Full Changelog: v0.10.0...v0.11.0

v0.10.0

11 Jun 20:58
2ccc350
Compare
Choose a tag to compare

What's Changed

This release is compatible with protovalidate v1.0.0-rc.2.

Full Changelog: v0.9.0...v0.10.0

v0.9.0

02 Jun 21:09
0622bf6
Compare
Choose a tag to compare

Breaking Changes

String formatting is now conformant with the CEL spec.

As a result, some formatting output may differ from previous versions. See #307 and #308 for details on formatting changes.

What's Changed

  • Add supplemental format conformance tests by @smaye81 in #308
  • Add conformance testing to string.format implementation by @smaye81 in #307

Full Changelog: v0.8.0...v0.9.0

v0.8.0

29 Apr 17:04
12155fb
Compare
Choose a tag to compare

What's Changed

protovalidate-python is now conformant with protovalidate v0.11.0, sans current known limitations (higher resolution timestamps/durations, which are not currently supported by the CEL implementation.) Various dependencies are also updated.

New Contributors

Full Changelog: v0.7.1...v0.8.0

v0.7.1

25 Feb 15:33
85b2b9f
Compare
Choose a tag to compare

The biggest change in this release is the upgrade to cel-python 0.2.0, which should help with some of the extraneous logging that users may have noticed.

What's Changed

Full Changelog: v0.7.0...v0.7.1

v0.7.0

07 Feb 21:24
4120a62
Compare
Choose a tag to compare

Breaking Changes

v0.7.0 removes support for the long-deprecated ignore_empty and skipped fields on FieldConstraints; protovalidate-python will no longer respect these options if they are set, and they are removed from the latest version of the protovalidate definitions.

What's Changed

New Contributors

Full Changelog: v0.6.1...v0.7.0

v0.6.1

15 Jan 18:25
3a82f01
Compare
Choose a tag to compare

The biggest change in this release is the support of PEP 561 (marking protovalidate as having type information inline), which should make usage of protovalidate with tools like mypy more seamless — see #243 for more details. Other than that, it's mostly dependency updates.

If coming from a release pre-v0.6.0, make sure to check out the release notes for that release when upgrading!

What's Changed

Full Changelog: v0.6.0...v0.6.1

v0.6.0

12 Dec 16:35
5e6ac7b
Compare
Choose a tag to compare

Breaking Changes

protovalidate.ValidationError has changed. The violations property is now a list of protovalidate.Violation, instead of a protobuf buf.validate.Violations message. In most cases, code will need to be updated like this:

     violations = protovalidate.collect_violations(msg)
-    print(violations.violations[0].constraint_id)
+    print(violations[0].proto.constraint_id)

The ValidationError.errors() method is removed in favor of the violations property, and a new ValidationError.to_proto() method is added to return the equivalent buf.validate.Violations.


In addition to containing the buf.validate.Violation protobuf message under the property proto, the new protovalidate.Violation class contains additional in-memory information about the violation which cannot be serialized to the wire:

  • field_value: Contains the value of the field failing validation, if there is a field corresponding to the violation.
  • rule_value: Contains the value of the rule failing validation, if there is a rule corresponding to the violation.

Take, for example, the following protobuf message schema:

message User {
    string email = 1 [(buf.validate.field).string.email = true];
}

If you try to validate the message User(email="invalid"), the field_value will be "invalid" and the rule_value will be True.

Some violations do not correspond directly to a field, such as a message constraint failure; in these cases, the field_value will be None.

What's Changed

Full Changelog: v0.5.0...v0.6.0

v0.5.0

26 Sep 19:19
3e2e3e3
Compare
Choose a tag to compare

Adds support for custom predefined field constraints. See the protovalidate documentation for more information.

Updates protovalidate to v0.8.1. Note that this is a breaking change. You may need to make some adjustments to your code:

  • Code that imports buf.validate.expression_pb2 or buf.validate.priv.private_pb2 should now only import buf.validate.validate_pb2.
  • buf.validate.priv.private_pb2.field was moved to buf.validate.validate_pb2.predefined

Note

This release updates protovalidate-python to use Protobuf Python v5+, which is not currently compatible with Protobuf Python v4 gencode. If you can not update to Protobuf Python v5 currently, you should continue to use protovalidate-python v0.3.1 for now.

What's Changed

Full Changelog: v0.4.0...v0.5.0