//
//  RuleEqualsIgnoreCaseModel.swift
//  MVMCoreUI
//
//  Created by Kevin Christiano on 5/15/20.
//  Copyright © 2020 Verizon Wireless. All rights reserved.
//

import Foundation


public class RuleEqualsIgnoreCaseModel: RuleCompareModelProtocol {
    //--------------------------------------------------
    // MARK: - Properties
    //--------------------------------------------------
    
    public static var identifier: String = "equalsIgnoreCase"
    public var type: String = RuleEqualsIgnoreCaseModel.identifier
    public var ruleId: String? 
    public var fields: [String]
    public var errorMessage: [String: String]?
    
    //--------------------------------------------------
    // MARK: - Initializer
    //--------------------------------------------------

    public init(fields: [String]) {
        self.fields = fields
    }

    //--------------------------------------------------
    // MARK: - Validation
    //--------------------------------------------------

    public func isValid(_ formField: FormFieldProtocol) -> Bool {
        return false
    }
    
    ///RuleCompareModelProtocol Method
    public func compare(lhs: String?, rhs: String?) -> Bool {
        guard let rhs = rhs else {
            return false
        }
        return lhs?.caseInsensitiveCompare(rhs) == .orderedSame
    }
}
