@jenova-marie/wonder-logger - v2.0.15
    Preparing search index...

    Function validateJSONStructure

    • Validate that the parsed result has expected structure

      Type Parameters

      • T = any

      Parameters

      • data: any

        The parsed data to validate

      • requiredFields: string[]

        Array of required field names

      Returns JSONResult<T>

      Result containing validated data, or error if structure is invalid

      const result = validateJSONStructure(data, ['name', 'version'])
      if (result.ok) {
      console.log('Valid structure:', result.value)
      } else {
      console.error('Missing fields:', result.error.context.missingFields)
      }