GithubHelp home page GithubHelp logo

gontard / scalapb-validate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from scalapb/scalapb-validate

0.0 0.0 0.0 163 KB

ScalaPB generator for PGV

License: Apache License 2.0

Scala 32.80% Starlark 8.07% C++ 4.83% Go 52.24% Python 1.33% Shell 0.56% Nix 0.17%

scalapb-validate's Introduction

Snapshot Artifacts

Running the test harness

PGV repo includes a comprehensive test suite defined over these proto files.

To run this test suite against scalapb-validate:

  1. 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.

  2. In SBT, run e2eJVM2_13/test:runMain scalapb.validate.ScalaHarness.

Adding the latest snapshot release to your project

  1. Note the latest snapshot version on Sonatype Snapshots

    Snapshot Artifacts

  2. 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
    
  3. Add the following to your build.sbt:

    ThisBuild / resolvers += Resolver.sonatypeRepo("snapshots")
    
    PB.targets in Compile := Seq(
      scalapb.gen() -> (sourceManaged in Compile).value / "scalapb",
      scalapb.validate.gen() -> (sourceManaged in Compile).value / "scalapb"
    )
    
    libraryDependencies ++= Seq(	
      "com.thesamet.scalapb" %% "scalapb-validate-core" % scalapb.validate.compiler.BuildInfo.version % "protobuf"	
    )
    
  4. import validate/validate.proto in your protobufs and set up validators as described in protoc-gen-validate documentation.

  5. 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.

scalapb-validate's People

Contributors

thesamet avatar tochemey avatar plaflamme avatar github-sebastien-boulet avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.