GeoLeaf Core API - v3.0.0
    Preparing search index...

    Function validateRequiredFields

    • Checks that an object carries a set of required top-level fields.

      Reports every missing field at once through the extra missing array, rather than stopping at the first — a configuration error is more useful complete.

      Parameters

      • config: Record<string, unknown> | null | undefined

        Object to inspect; null or undefined counts every field as missing.

      • requiredFields: string[]

        Names that must be present.

      • options: ValidatorOptions = {}

      Returns { valid: boolean; error: string | null; missing: string[] }

      { valid, error, missing }, where missing lists the absent names.

      GeoLeafError A ValidationError when fields are missing and throwOnError is set.

      const config = { map: { target: "my-map" } };

      const result = GeoLeaf.Validators.validateRequiredFields(config, ["map", "layers"]);
      // Returns: { valid: false, error: 'Missing required fields: layers', missing: ['layers'] }

      const result2 = GeoLeaf.Validators.validateRequiredFields(config, ["map"]);
      // Returns: { valid: true, error: null, missing: [] }