19 lines
410 B
Swift
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
|
|
}
|
|
}
|