Class OptionsValidator

java.lang.Object
growthbook.sdk.java.multiusermode.configurations.OptionsValidator

public final class OptionsValidator extends Object
Validates Options once, at client start-up, so misconfigurations are reported up front with a clear message instead of surfacing later as an opaque fetch failure.

All independent problems are collected and reported together, so a caller fixing several misconfigured options sees every issue at once rather than one per restart.

Checks performed:

  • apiHost is present and a syntactically valid http(s) URL.
  • clientKey is present.
  • swrTtlSeconds (refresh interval) is positive when set.
  • backgroundFetchInterval is non-negative when set.
  • remoteEvalCacheTtlSeconds is positive when set.
  • No contradictory cache configuration (e.g. a cacheManager supplied while caching is disabled, or CacheMode.CUSTOM without a cacheManager).
  • Remote-eval incompatibilities, delegated to RemoteEvalOptionsValidator#remoteEvalViolations so all problems surface together.
  • Method Details

    • validate

      public static void validate(@Nullable Options options)
      Validates the supplied options, throwing when any option is invalid or contradictory.
      Parameters:
      options - client options to validate; null is treated as nothing to validate
      Throws:
      InvalidOptionsException - listing every problem found (a subtype of IllegalArgumentException)
    • findViolations

      public static List<String> findViolations(@Nullable Options options)
      Collects every validation problem without throwing.
      Parameters:
      options - client options to inspect; null yields an empty list
      Returns:
      an immutable list of human-readable problem descriptions, empty when valid