Skip to content

Validatable

mattpolzin edited this page Jun 11, 2021 · 3 revisions

Validatable

A Marker protocol that indicates a type can be used as the subject of a Validation.

public protocol Validatable 

Another way to say that is that these are the types that can be used to specialize ValidationContext<Subject>.

As a general rule, you can assume that almost all types under the OpenAPI namespace are validatable; Other types provided by this library, like the various Dereferenced types are generally not validatable.

Example:

// In this call to `validating()`,
// `OpenAPI.Document` is Validatable.
Validator().validating(
    "Using OpenAPI v 3.0.0",
    check: \OpenAPI.Document.openAPIVersion == .v3_0_0
)

Example:

// In this Validation construction,
//  `OpenAPI.Content.Map` is Validatable
let allRoutesOfferJSON = Validation(
    description: "All content maps have JSON members.",
    check: \OpenAPI.Content.Map[.json] != nil
)
Types
Protocols
Global Functions
Extensions
Clone this wiki locally