ts.data.json - v4.1.0
    Preparing search index...

    Function record

    • Decoder for record types with string keys.

      Type Parameters

      • V

      Parameters

      • decoder: Decoder<V>

        The decoder for the record values

      Returns Decoder<{ [K: string]: V }>

      A decoder that validates and returns a record with string keys

      const numberRecord = JsonDecoder.record(JsonDecoder.number());

      numberRecord.decode({a: 1, b: 2}); // Ok<Record<string, number>>

      // All value failures are collected before returning:
      numberRecord.decode({a: '1', b: '2'});
      // Err({ issues: [
      // { message: '"1" is not a valid number', path: ['a'] },
      // { message: '"2" is not a valid number', path: ['b'] }
      // ] })