You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 8, 2021. It is now read-only.
Leaking such class into the application would be very annoying, as it required developers to handle Options even when value is always going to be there (at least in this specific version of the protocol).
Refined types
At Cakesolutions we are fans of Refined types, we use it in our model classes.
While you can instruct ScalaPb to generate custom types (making use of Refined types?), this pollutes the proto file with Scala snippets, which defies the purpose of using proto files if you use multiple languages.
Solution
Refined allow you to own you model classes, which can use "Stricter" types, then get's automatically to converted from/to Proto buff (generated via ScalaPb)
Example:
Given a protofile similar to
syntax="proto3";
packagecom.example.protocol;
import"google/protobuf/wrappers.proto";
messageEmployeeData {
// logically required (beware, ScalaPb sets default value to Zero)int32id=1;
// logically required, non-empty// beware: ScalaPb sets default value to empty string// However, our Refined types in the crossponding model should catch this.stringname=2;
// logically optional, Postive (using Google wrapper to allow optional)google.protobuf.Int32Valueage=20;
}