Validate
@propertyWrapper
public struct Validate<Value> : DynamicProperty
A property wrapper that can validate the property it wraps.
When the wrapped value changes @Validate
will run the provided
validations against the value.
Once validated, the isValid
and errors
properties can provide
validation results.
The Validate
framwork contains a number of built in validations such
as presence, count and format. All which a various array of types.
If the included validations don’t quite do what is required, new validations
can be built with the Validation
struct.
-
The wrapped value
Declaration
Swift
public var wrappedValue: Value { get nonmutating set }
-
Undocumented
Declaration
Swift
public var projectedValue: Binding<Value> { get }
-
The errors produced when validating the wrapped value.
Declaration
Swift
public var errors: [Error] { get }
-
Indicates whether the wrapped value is valid.
Declaration
Swift
public var isValid: Bool { get }
-
Initialize a
Validate
instance.Declaration
Swift
public init( wrappedValue: Value, _ validations: Validation<Value>... )
Parameters
wrappedValue
The value to wrap.
validations
The validations.
-
Initialize a
Validate
instance where Value is optional.Declaration
Swift
public init<T>( wrappedValue: Value, _ validations: Validation<Value>... ) where Value == Optional<T>
Parameters
wrappedValue
The value to wrap.
validations
The validations.