//
//  FormFieldProtocol.swift
//  MVMCoreUI
//
//  Created by Suresh, Kamlesh on 1/31/20.
//  Copyright © 2020 Verizon Wireless. All rights reserved.
//
//  Form fields are items can be interacted with. They have value, and may need to be validated.


public protocol FormFieldProtocol: FormItemProtocol {
    
    /// How the validator identifies the field when validating rules.
    var fieldKey: String? { get set }
    
    /// A place to store the initial value of the field for checking if the value has changed.
    var baseValue: AnyHashable? { get set }
    
    ///Bool to determine a state that is different from disabled. Readonly values will be sent
    ///to the server where disabled fields are not
    var readOnly: Bool { get set }
    
    /// Returns the value of the field. Used for validations and possibly for sending to server.
    func formFieldValue() -> AnyHashable?

}

public extension FormFieldProtocol {
    
    var baseValue: AnyHashable? { nil }
}
