PurchaseForm

public struct PurchaseForm

A series of grouped questions and answers to those questions

  • The groups of questions

    Declaration

    Swift

    public let questionGroups: [QuestionGroup]
  • Adds the supplied answer to the PurchaseForm. If the question had already been answered this will replace the answer with the new one.

    Throws

    PurchaseFormError.invalidQuestion if the Question the supplied Answer answers did not belong to the form

    Declaration

    Swift

    public mutating func addAnswer(_ answer: Answer) throws
  • Retrieves a previously added Answer from the form for the supplied Question if there is any

    Throws

    PurchaseForm.invalidQuestion if the Question was not part of this form

    Declaration

    Swift

    public func answer(for question: Question) throws -> Answer?

    Return Value

    The previously supplied Answer, if none was supplied nil will be returned

  • Validates all answers in the form, using their respective Questions ValidationRule

    Declaration

    Swift

    public func validate() -> [PurchaseFormError]

    Return Value

    An Array<PurchaseFormError> representing all the validation errors inside the form