Fields

public struct Fields

Fields has static constructors for field extractors that can be used when the result value is still undefined. These constructors are useful for complex field compositions.

For example:

Fields.at("data", "arrayOfArrays").get(
    asArrayOf: Fields.get(asArrayOf: Field<String>())
)

// Resulting type: Field<[[String]]>
  • Creates a field extractor with the provided segments.

    Declaration

    Swift

    public static func at(_ segments: Segment...) -> Field<Value>
  • Creates a field extractor with the provided path.

    Declaration

    Swift

    public static func at(path segments: [Segment]) -> Field<Value>
  • Uses the field extractor provided to create new array field.

    Declaration

    Swift

    public static func get<A>(asArrayOf field: Field<A>) -> Field<[A]>
  • Uses the field extractor provided to create new object field.

    Declaration

    Swift

    public static func get<A>(asDictionaryOf field: Field<A>) -> Field<[String: A]>
  • Creates a field extractor by mapping its result to the function provided.

    Declaration

    Swift

    public static func map<A>(_ transform: @escaping (Value) throws -> A) -> Field<A>
  • Creates a field extractor by flat mapping its result to the function provided.

    Declaration

    Swift

    public static func flatMap<A>(_ transform: @escaping (Value) throws -> A?) -> Field<A>