From d04853538f2261d02c2b7cc30255d4608111cc95 Mon Sep 17 00:00:00 2001 From: Red Davis Date: Thu, 3 Mar 2022 11:35:06 +0000 Subject: [PATCH] Add couple cleaner initializers if not being used as a property wrapper --- Validate/Source/Validate.swift | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Validate/Source/Validate.swift b/Validate/Source/Validate.swift index a0fa328..77711a2 100644 --- a/Validate/Source/Validate.swift +++ b/Validate/Source/Validate.swift @@ -74,6 +74,28 @@ public struct Validate: DynamicProperty { self.init(wrappedValue: wrappedValue, validations: validations) } + /// Initialize a `Validate` instance. + /// - Parameters: + /// - value: The value to validate. + /// - validations: The validations. + public init( + _ value: Value, + validations: Validation... + ) { + self.init(wrappedValue: value, validations: validations) + } + + /// Initialize a `Validate` instance where Value is optional. + /// - Parameters: + /// - value: The value to validate. + /// - validations: The validations. + public init( + _ value: Value, + validations: Validation... + ) where Value == Optional { + self.init(wrappedValue: value, validations: validations) + } + init( wrappedValue: Value, validations: [Validation]