Skip to content

Commit

Permalink
Add couple cleaner initializers if not being used as a property wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
reddavis committed Mar 3, 2022
1 parent a31e251 commit d048535
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Validate/Source/Validate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,28 @@ public struct Validate<Value>: 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<Value>...
) {
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<T>(
_ value: Value,
validations: Validation<Value>...
) where Value == Optional<T> {
self.init(wrappedValue: value, validations: validations)
}

init(
wrappedValue: Value,
validations: [Validation<Value>]
Expand Down

0 comments on commit d048535

Please sign in to comment.