Class ValidatorFactory.ValidatorBuilder

java.lang.Object
build.buf.protovalidate.ValidatorFactory.ValidatorBuilder
Enclosing class:
ValidatorFactory

public static class ValidatorFactory.ValidatorBuilder extends Object
A builder class used for building a validator.
  • Method Details

    • withConfig

      public ValidatorFactory.ValidatorBuilder withConfig(Config config)
      Create a validator with the given config
      Parameters:
      config - The Config to configure the validator.
      Returns:
      The builder instance
    • build

      public Validator build()
      Build a new validator
      Returns:
      A new Validator instance.
    • buildWithDescriptors

      public Validator buildWithDescriptors(List<com.google.protobuf.Descriptors.Descriptor> descriptors, boolean disableLazy) throws CompilationException, IllegalStateException
      Build the validator, warming up the cache with any provided descriptors.
      Parameters:
      descriptors - the list of descriptors to warm up the cache.
      disableLazy - whether to disable lazy loading of validation rules. When validation is performed, a message's rules will be looked up in a cache. If they are not found, by default they will be processed and lazily-loaded into the cache. Setting this to false will not attempt to lazily-load descriptor information not found in the cache and essentially makes the entire cache read-only, eliminating thread contention.
      Returns:
      A new Validator instance.
      Throws:
      CompilationException - If any of the given descriptors' validation rules fail processing while warming up the cache.
      IllegalStateException - If disableLazy is set to true and no descriptors are passed.