Merge branch 'develop' into feature/radio_swatches
This commit is contained in:
commit
465fb26e8a
@ -276,7 +276,7 @@ import UIKit
|
|||||||
let fallbackImageName = customFallbackImage ?? MVMCoreUIUtility.localizedImageName("fallback")
|
let fallbackImageName = customFallbackImage ?? MVMCoreUIUtility.localizedImageName("fallback")
|
||||||
if let format = format, format.lowercased().contains("gif") {
|
if let format = format, format.lowercased().contains("gif") {
|
||||||
// Gifs aren't supported by default and need special handling
|
// Gifs aren't supported by default and need special handling
|
||||||
MVMCoreCache.shared()?.getGif(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, completionHandler: finishedLoadingBlock)
|
MVMCoreCache.shared()?.getGif(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, localBundle: localBundle, completionHandler: finishedLoadingBlock)
|
||||||
} else {
|
} else {
|
||||||
MVMCoreCache.shared()?.getImage(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, localBundle: localBundle, completionHandler: finishedLoadingBlock)
|
MVMCoreCache.shared()?.getImage(imageName, useWidth: width != nil, widthForS7: width?.intValue ?? 0, useHeight: height != nil, heightForS7: height?.intValue ?? 0, format: format, localFallbackImageName: fallbackImageName, allowServerQueryParameters: allowServerParameters, localBundle: localBundle, completionHandler: finishedLoadingBlock)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,7 +89,7 @@ import MVMCore
|
|||||||
// Validate each rule.
|
// Validate each rule.
|
||||||
var valid = true
|
var valid = true
|
||||||
for rule in group.rules {
|
for rule in group.rules {
|
||||||
valid = valid && validateRule(rule)
|
valid = valid && rule.validate(fields)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify the group watchers of validity.
|
// Notify the group watchers of validity.
|
||||||
@ -98,19 +98,6 @@ import MVMCore
|
|||||||
watcher.setValidity(valid, group: group)
|
watcher.setValidity(valid, group: group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return valid
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Validates a given rule. Returns if valid.
|
|
||||||
public func validateRule(_ rule: RulesProtocol) -> Bool {
|
|
||||||
var valid = true
|
|
||||||
for formKey in rule.fields {
|
|
||||||
guard let formField = fields[formKey] else { continue }
|
|
||||||
let fieldValidity = rule.isValid(formField)
|
|
||||||
(formField as? FormRuleWatcherFieldProtocol)?.setValidity(fieldValidity, rule: rule)
|
|
||||||
valid = valid && fieldValidity
|
|
||||||
}
|
|
||||||
return valid
|
return valid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,7 @@ public class RuleAnyRequiredModel: RulesProtocol {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool {
|
public func validate(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool {
|
||||||
|
|
||||||
for formKey in fields {
|
for formKey in fields {
|
||||||
guard let formField = fieldMolecules[formKey] else { continue }
|
guard let formField = fieldMolecules[formKey] else { continue }
|
||||||
|
|||||||
@ -26,16 +26,13 @@ public class RuleAnyValueChangedModel: RulesProtocol {
|
|||||||
return formField.baseValue != formField.formFieldValue()
|
return formField.baseValue != formField.formFieldValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool {
|
public func validate(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool {
|
||||||
|
|
||||||
for formKey in fields {
|
for formKey in fields {
|
||||||
guard let formField = fieldMolecules[formKey] else { continue }
|
guard let formField = fieldMolecules[formKey] else { continue }
|
||||||
|
|
||||||
if isValid(formField) {
|
if isValid(formField) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,8 +26,7 @@ public class RuleEqualsModel: RulesProtocol {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isValid(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool {
|
public func validate(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool {
|
||||||
|
|
||||||
var valid = true
|
var valid = true
|
||||||
var compareValue: AnyHashable?
|
var compareValue: AnyHashable?
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,9 @@ public protocol RulesProtocol: ModelProtocol {
|
|||||||
|
|
||||||
// Returns if a given field is valid according to the rule
|
// Returns if a given field is valid according to the rule
|
||||||
func isValid(_ formField: FormFieldProtocol) -> Bool
|
func isValid(_ formField: FormFieldProtocol) -> Bool
|
||||||
|
|
||||||
|
// Validates the rule and returns the result.
|
||||||
|
func validate(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension RulesProtocol {
|
public extension RulesProtocol {
|
||||||
@ -37,4 +40,16 @@ public extension RulesProtocol {
|
|||||||
static var categoryName: String {
|
static var categoryName: String {
|
||||||
return "\(RulesProtocol.self)"
|
return "\(RulesProtocol.self)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Individual rule can override the function to validate based on the rule type.
|
||||||
|
func validate(_ fieldMolecules: [String: FormFieldProtocol]) -> Bool {
|
||||||
|
var valid = true
|
||||||
|
for formKey in fields {
|
||||||
|
guard let formField = fieldMolecules[formKey] else { continue }
|
||||||
|
let fieldValidity = isValid(formField)
|
||||||
|
(formField as? FormRuleWatcherFieldProtocol)?.setValidity(fieldValidity, rule: self)
|
||||||
|
valid = valid && fieldValidity
|
||||||
|
}
|
||||||
|
return valid
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user