Function assertFormData

  • Form data decoder with type assertion.

    typia.http.assertFormData() is a function decoding FormData instance, with automatic type casting to the expected type. When roperty type be defined as boolean or Blob type, typia.http.assertFormData() will cast the value to the expected type when decoding.

    Also, after decoding, typia.http.assertFormData() performs type assertion to the decoded value by combining with assert function. Therefore, when the decoded value is not following the T type, TypeGuardError or custom error generated by errorFactory would be thrown.

    By the way, as FormData is not enough to express complex data structures, typia.http.assertFormData() function has some limitations. If target type T is not following those restrictions, compilation errors would be occured.

    1. Type T must be an object type
    2. Do not allow dynamic property
    3. Only boolean, bigint, number, string, Blob, File or their array types are allowed
    4. By the way, union type never be not allowed

    Type Parameters

    • T extends object

      Expected type of decoded value

    Parameters

    • input: FormData

      FormData instance

    • OptionalerrorFactory: ((props: TypeGuardError.IProps) => Error)

      Custom error factory. Default is TypeGuardError

    Returns Resolved<T>

    Decoded form FormData

    Jeongho Nam - https://github.com/samchon