Discover Packages
github.com/scalapb/scalapb-validate
module
Version:
v0.2.2
Opens a new window with list of versions in this module.
Published: Feb 16, 2021
License: Apache-2.0
Opens a new window with license information.
README
README
¶
Running the test harness
PGV repo includes a comprehensive test suite defined over these proto files .
To run this test suite against scalapb-validate:
Run ./make_harness.sh
. This will download bazelisk , clone PGV, and compile its test executor. It is only needed to be done once, and can take a few minutes to compile.
In SBT, run e2eJVM2_13/test:runMain scalapb.validate.ScalaHarness
.
Adding the latest snapshot release to your project
Note the latest snapshot version on Sonatype Snapshots
Add the following to your project/plugins.sbt
, replace the
validateVersion value with the snapshot version you have found in the
previous step:
ThisBuild / resolvers += Resolver.sonatypeRepo("snapshots")
addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.34")
libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.10.8"
val validateVersion = "0.1.2"
libraryDependencies += "com.thesamet.scalapb" %% "scalapb-validate-codegen" % validateVersion
Add the following to your build.sbt
:
ThisBuild / resolvers += Resolver.sonatypeRepo("snapshots")
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value / "scalapb",
scalapb.validate.gen() -> (Compile / sourceManaged).value / "scalapb"
)
libraryDependencies ++= Seq(
"com.thesamet.scalapb" %% "scalapb-validate-core" % scalapb.validate.compiler.BuildInfo.version % "protobuf"
)
import validate/validate.proto
in your protobufs and set up validators as described in protoc-gen-validate documentation .
The generated code will generate a Validator object for each message class. For example, if you have a Person
message, it will generate a PersonValidator
object that has a validate(instance: Person)
method that returns a validation Result
.
Examples
See a full example at the examples directory .
Expand ▾
Collapse ▴
Directories
¶
e2e
Click to show internal directories.
Click to hide internal directories.