FxFields

public class FxFields<E:Hashable>: FxBase, Sequence

Reactive class that manages a list of FxFields.

  • Undocumented

    Declaration

    Swift

    public var list = [FxField<E>]()
  • map

    Undocumented

    Declaration

    Swift

    public var map = [String : FxField<E>]()
  • Undocumented

    Declaration

    Swift

    override public init()
  • Clears all managed field values.

    Declaration

    Swift

    public func clear()
  • Constructs a FxField with the specified id and adds it to the list of managed fields.

    fields.add(.zip).required()
    

    Declaration

    Swift

    public func add(_ id: E) -> FxField<E>

    Parameters

    id

    Unique id of field to add.

    Return Value

    FxField for further configuration.

  • Adds field to the list of managed fields.

    let field = FxField<E>(ContactFields.zip)
    fields.add(field).required()
    

    Declaration

    Swift

    public func add(_ field: FxField<E>) -> FxField<E>

    Parameters

    field

    FxField to add.

    Return Value

    FxField for further configuration.

  • Returns FxField with the given id.

    Declaration

    Swift

    public subscript(_ id: E) -> FxField<E>?
  • Returns iterator that will sequence through all managed FxField‘s.

    Declaration

    Swift

    public func makeIterator() -> FxFieldsIterator<E>
  • Clears all field errors.

    Declaration

    Swift

    public func clearErrors()
  • Returns the validation state of all managed fields.

    if fields.isValid() {
        save()
    }
    

    Declaration

    Swift

    public func isValid() -> Bool
  • Returns a list of all managed fields with errors.

    for badField in fields.errorFields() { ... }
    

    Declaration

    Swift

    public var errorFields: [FxField<E>]
  • Returns a list of error messages for all invalid fields.

    for message in fields.errorMessages() { ... }
    

    Declaration

    Swift

    public var errorMessages: [String]
  • Returns a formatted string of error messages for all invalid fields.

    let errors = fields.errorMessagesAsString()
    showErrorMessage("Errors:\n" + errors)
    

    Declaration

    Swift

    public func errorMessagesAsString(separatedBy separator:String = "\n") -> String