Skip to content

Releases: bufbuild/protovalidate-python

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 Change: 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

v0.4.0

15 Aug 16:22
4c035d0
Compare
Choose a tag to compare

This release adds support for the string.host_and_port CEL utility function and Protobuf Editions, and bumps the versions of many of the dependencies.

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

New Contributors

Full Changelog: v0.3.1...v0.4.0

v0.3.1

12 Dec 20:25
30fb873
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.3.0...v0.3.1

v0.3.0

31 Oct 18:02
3f87f79
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.2.1...v0.3.0

v0.2.1

25 Aug 20:42
4afaea4
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.2.0...v0.2.1

v0.2.0

23 Aug 21:16
084944d
Compare
Choose a tag to compare

Breaking Change: Refactoring of Schema-Level Constraint Enforcement

Summary:

In the recent changes to buf/validate/validate.proto, we've refactored message definitions, targeting the organization and enforcement of rules within number-centric messages like FloatRules, DoubleRules, Int32Rules, and others.

Specific Changes:

Fields such as gt, gte, lt, and lte have been structured within a oneof to ensure exclusivity:
- Fields associated with lt and lte now reside within the less_than oneof.
- Fields linked to gt and gte have transitioned to the greater_than oneof.

Additionally, timestamp and duration fields related to lt_now and gt_now have been assimilated into their respective less_than and greater_than oneof categories.

Action Required:

To ensure seamless compatibility and functionality, users must update their protobuf dependencies and package concurrently with this release. If your protos were designed with mutually exclusive rules initially, the impact of this change should be minimal.

Rationale:

The restructure aims to make the rule application process more intuitive, thereby eliminating ambiguities and overlaps present in the earlier configuration. This approach ensures that rules are naturally exclusive, reinforcing better design practices.

What's Changed

  • Add support for for_key and update protovalidate dep by @Alfus in #63
  • Add support for isNan and isInf by @Alfus in #64

Full Changelog: v0.1.0...v0.2.0

v0.1.0

13 Jul 07:58
25dda3f
Compare
Choose a tag to compare

We are excited to introduce protovalidate-python v0.1.0, the Python implementation of protovalidate, providing runtime validation for Protobuf messages based on user-defined constraints, powered by Google's Common Expression Language (CEL).

Key Features

  • Protobuf Validation: Validate Protobuf messages at runtime with user-defined rules.
  • CEL Support: Define comprehensive validation rules using Google's CEL.
  • Efficiency: Designed for performance and minimal system resource usage.
  • Flexibility: Create custom validation rules to suit specific needs.

Refer to our official documentation for detailed instructions. For any issues or suggestions, please open an issue on our GitHub page. Stay tuned for future updates.

Full Changelog: https://github.com/bufbuild/protovalidate-python/commits/v0.1.0