File tree Expand file tree Collapse file tree
Sources/ValidatorUI/Classes/SUI/Extensions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,29 @@ import ValidatorCore
1111private let validator = Validator ( )
1212
1313public extension View {
14+ /// Validate a binding item using a set of validation rules and perform an action based on
15+ /// the validation result.
16+ ///
17+ /// This function takes a binding item, a validation rule, and a closure to handle
18+ /// the validation result.
19+ /// It validates the wrapped value of the binding item against the specified rule and then
20+ /// invokes the provided action with the result.
21+ ///
22+ /// - Parameters:
23+ /// - item: The binding item to validate.
24+ /// - rule: A validation rule to apply to the item's value.
25+ /// - action: A closure that takes a `ValidationResult` as its parameter.
26+ /// This closure is called with the validation result after the validation is performed.
27+ ///
28+ /// - Returns: A view that can be modified further or used in your SwiftUI hierarchy.
29+ func validation< T> (
30+ _ item: Binding < T > ,
31+ rule: some IValidationRule < T > ,
32+ action: @escaping ( ValidationResult ) -> Void
33+ ) -> some View {
34+ validation ( item, rules: [ rule] , action: action)
35+ }
36+
1437 /// Validate a binding item using a set of validation rules and perform an action based on
1538 /// the validation result.
1639 ///
You can’t perform that action at this time.
0 commit comments