vds_ios/VDS/Components/TextFields/Rules/CharacterCountRule.swift
Matt Bruce cfc21c2727 added internal rules
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2024-04-30 14:10:36 -05:00

19 lines
410 B
Swift

//
// CharacterCountRule.swift
// VDS
//
// Created by Matt Bruce on 4/30/24.
//
import Foundation
class CharacterCountRule: Rule {
var maxLength: Int?
var errorMessage: String = "You have exceeded the character limit."
func isValid(value: String?) -> Bool {
guard let text = value, let maxLength, maxLength > 0 else { return true }
return text.count <= maxLength
}
}