From 8e486f9301003734da636e255b292ff8258e4834 Mon Sep 17 00:00:00 2001 From: Keerthy Date: Thu, 29 Sep 2022 19:52:00 +0530 Subject: [PATCH] Added RuleNotEquals form rule PREGRO-5736 --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++ .../Rules/Rules/RuleNotEqualsModel.swift | 44 +++++++++++++++++++ .../OtherHandlers/CoreUIModelMapping.swift | 1 + 3 files changed, 49 insertions(+) create mode 100644 MVMCoreUI/FormUIHelpers/Rules/Rules/RuleNotEqualsModel.swift diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index df9843e1..9f29106c 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -602,6 +602,7 @@ EAB14BC327D9378D0012AB2C /* RuleAnyModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */; }; EABFC1412763BB8D00E78B40 /* FormLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABFC1402763BB8D00E78B40 /* FormLabel.swift */; }; EABFC152276913E800E78B40 /* FormLabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EABFC151276913E800E78B40 /* FormLabelModel.swift */; }; + FD99130028E21E4900542CC3 /* RuleNotEqualsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD9912FF28E21E4900542CC3 /* RuleNotEqualsModel.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -1203,6 +1204,7 @@ EAB14BC227D9378D0012AB2C /* RuleAnyModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleAnyModelProtocol.swift; sourceTree = ""; }; EABFC1402763BB8D00E78B40 /* FormLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabel.swift; sourceTree = ""; }; EABFC151276913E800E78B40 /* FormLabelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormLabelModel.swift; sourceTree = ""; }; + FD9912FF28E21E4900542CC3 /* RuleNotEqualsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RuleNotEqualsModel.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -1257,6 +1259,7 @@ 0A69F610241BDEA700F7231B /* RuleAnyRequiredModel.swift */, 011D95A0240453D0000E3791 /* RuleEqualsModel.swift */, 0A849EFD246F1775009F277F /* RuleEqualsIgnoreCaseModel.swift */, + FD9912FF28E21E4900542CC3 /* RuleNotEqualsModel.swift */, ); name = Rules; path = Rules/Rules; @@ -2956,6 +2959,7 @@ D2509ED12472ED9B001BFB9D /* NavigationItemModelProtocol.swift in Sources */, EA05EFAB278DE53600828819 /* ClearableModelProtocol.swift in Sources */, 8D448E5524050A46006211BB /* ListOneColumnFullWidthTextAllTextAndLinksModel.swift in Sources */, + FD99130028E21E4900542CC3 /* RuleNotEqualsModel.swift in Sources */, BBC0C4FD24811DBC0087C44F /* Tag.swift in Sources */, 94C2D9842386F3F80006CF46 /* LabelAttributeModel.swift in Sources */, 944589212385D6E900DE9FD4 /* DashLineModel.swift in Sources */, diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleNotEqualsModel.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleNotEqualsModel.swift new file mode 100644 index 00000000..1cd8bb74 --- /dev/null +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RuleNotEqualsModel.swift @@ -0,0 +1,44 @@ +// +// RuleNotEqualsModel.swift +// MVMCoreUI +// +// Created by Marakanti, Keerthy on 26/09/22. +// Copyright © 2022 Verizon Wireless. All rights reserved. +// + +import Foundation + +public class RuleNotEqualsModel: RuleCompareModelProtocol { + //-------------------------------------------------- + // MARK: - Properties + //-------------------------------------------------- + + public static var identifier: String = "notEquals" + public var type: String = RuleNotEqualsModel.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: AnyHashable?, rhs: AnyHashable?) -> Bool { + return lhs != rhs + } + +} + diff --git a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift index 061c67fb..3e5357ea 100644 --- a/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/CoreUIModelMapping.swift @@ -244,6 +244,7 @@ open class CoreUIModelMapping: ModelMapping { ModelRegistry.register(RuleAnyValueChangedModel.self) ModelRegistry.register(RuleAllValueChangedModel.self) ModelRegistry.register(RuleEqualsModel.self) + ModelRegistry.register(RuleNotEqualsModel.self) ModelRegistry.register(RuleEqualsIgnoreCaseModel.self) ModelRegistry.register(RuleRegexModel.self) ModelRegistry.register(EnableFormFieldEffectModel.self)