ENUM
HaapiModel.ProblemFactory
Contents
- Methods
problem(type:metadata:title:messages:links:)
invalidInputField(name:reason:detail:)
invalidInput(invalidFields:errorDescription:type:metadata:title:messages:links:)
authorization(error:errorDescription:type:metadata:title:messages:links:)
enum ProblemFactory
Provides functionality to build instances of Problem
.
Methods
problem(type:metadata:title:messages:links:)
public static func problem(type: ProblemType,
metadata: Metadata?,
title: Message?,
messages: [UserMessage],
links: [Link]) -> Problem
Creates an instance of Problem
model.
-
Parameters:
- type: The represented
ProblemType
value. - metadata: Additional information about the problem.
- title: The title of the error.
- messages: An array of messages to be displayed to the user.
- links: An array of
Link
instances that can be used to choose an alternate path for the flow.
- type: The represented
-
Returns: A built instance of
Problem
.
Parameters
Name | Description |
---|---|
type | The represented ProblemType value. |
metadata | Additional information about the problem. |
title | The title of the error. |
messages | An array of messages to be displayed to the user. |
links | An array of Link instances that can be used to choose an alternate path for the flow. |
invalidInputField(name:reason:detail:)
public static func invalidInputField(name: String,
reason: String?,
detail: Message) -> InvalidInputProblem.InvalidField
Creates an instance of InvalidInputProblem.InvalidField
model.
-
Parameters:
- name: The name of the invalid field
- reason: The reason for the field to be invalid
- detail: Additional details about why the field is invalid
-
Returns: A built instance of
InvalidInputProblem.InvalidField
.
Parameters
Name | Description |
---|---|
name | The name of the invalid field |
reason | The reason for the field to be invalid |
detail | Additional details about why the field is invalid |
invalidInput(invalidFields:errorDescription:type:metadata:title:messages:links:)
public static func invalidInput(invalidFields: [InvalidInputProblem.InvalidField], // swiftlint:disable:this function_parameter_count line_length
errorDescription: String?,
type: ProblemType,
metadata: Metadata?,
title: Message?,
messages: [UserMessage],
links: [Link]) -> InvalidInputProblem
Creates an instance of InvalidInputProblem
model.
-
Parameters:
- invalidFields: An array of
InvalidInputProblem.InvalidField
instances to match the errors to the appropriate fields. - errorDescription: A human readable error description. Provides additional error information.
- type: The represented
ProblemType
value. - metadata: Additional information about the problem.
- title: The title of the error.
- messages: An array of messages to be displayed to the user.
- links: An array of
Link
instances that can be used to choose an alternate path for the flow.
- invalidFields: An array of
-
Returns: A built instance of
InvalidInputProblem
.
Parameters
Name | Description |
---|---|
invalidFields | An array of InvalidInputProblem.InvalidField instances to match the errors to the appropriate fields. |
errorDescription | A human readable error description. Provides additional error information. |
type | The represented ProblemType value. |
metadata | Additional information about the problem. |
title | The title of the error. |
messages | An array of messages to be displayed to the user. |
links | An array of Link instances that can be used to choose an alternate path for the flow. |
authorization(error:errorDescription:type:metadata:title:messages:links:)
public static func authorization(error: String, // swiftlint:disable:this function_parameter_count
errorDescription: String?,
type: ProblemType,
metadata: Metadata?,
title: Message?,
messages: [UserMessage],
links: [Link]) -> AuthorizationProblem
Creates an instance of AuthorizationProblem
model.
-
Parameters:
- error: The error code.
- errorDescription: A human readable error description. Provides additional error information.
- type: The represented
ProblemType
value. - metadata: Additional information about the problem.
- title: The title of the error.
- messages: An array of messages to be displayed to the user.
- links: An array of
Link
instances that can be used to choose an alternate path for the flow.
-
Returns: A built instance of
AuthorizationProblem
.
Parameters
Name | Description |
---|---|
error | The error code. |
errorDescription | A human readable error description. Provides additional error information. |
type | The represented ProblemType value. |
metadata | Additional information about the problem. |
title | The title of the error. |
messages | An array of messages to be displayed to the user. |
links | An array of Link instances that can be used to choose an alternate path for the flow. |