ValidationRule

struct ValidationRule
extension EUDCC.ValidationRule: Equatable
extension EUDCC.ValidationRule: Hashable

An EUDCC ValidationRule

Typealias

  • The predicate typealias

    Declaration

    Swift

    public typealias Predicate = (EUDCC) -> Bool

Properties

  • tag

    The Tag

    Declaration

    Swift

    public let tag: Tag

Initializer

  • Creates a new instance of EUDCC.ValidationRule

    Declaration

    Swift

    public init(
        tag: Tag = .init(),
        predicate: @escaping Predicate
    )

    Parameters

    tag

    The Tag. Default value .init()

    predicate

    The predicate closure

ValidationRule+CompareAgainst

ValidationRule+Compare

  • Compare value of a given KeyPath to another value using an operator

    Declaration

    Swift

    static func compare<Value>(
        value: CompareAgainst<Value>,
        to compareAgainstValue: CompareAgainst<Value>,
        operator: @escaping (Value, Value) -> Bool,
        tag: Tag = .init()
    ) -> Self

    Parameters

    keyPath

    The KeyPath to the value of the EUDCC

    compareAgainstValue

    The value to compare against

    operator

    The operator used for comparison

    tag

    The Tag. Default value .init()

    Return Value

    A ValidationRule

ValidationRule+CompareDate

  • The CompareAgainstDate Parameter

    See more

    Declaration

    Swift

    struct CompareAgainstDate
  • Compare two Dates using a given operator

    Declaration

    Swift

    static func compare(
        lhsDate: CompareAgainstDate,
        rhsDate: CompareAgainstDate,
        operator: @escaping (Date, Date) -> Bool,
        using calendar: Calendar = .current,
        tag: Tag = .init()
    ) -> Self

    Parameters

    lhsDate

    The left-hand-side CompareAgainstDate

    rhsDate

    The right-hand-side CompareAgainstDate

    operator

    The operator closure

    calendar

    The Calendar. Default value .current

    tag

    The Tag. Default value .init()

ValidationRule+Equal

  • Returns a ValidationRule where two given ValidationRules results will be compared to equality

    Declaration

    Swift

    static func == (
        lhs: Self,
        rhs: Self
    ) -> Self

    Parameters

    lhs

    The left-hand side of the operation

    rhs

    The right-hand side of the operation

ValidationRule+Unequal

  • Returns a ValidationRule where two given ValidationRule results will be compared to unequality

    Declaration

    Swift

    static func != (
        lhs: Self,
        rhs: Self
    ) -> Self

    Parameters

    lhs

    The left-hand side of the operation

    rhs

    The right-hand side of the operation

Constant

  • Constant ValidationRule that will always return the given Bool result value

    Declaration

    Swift

    static func constant(
        _ result: Bool
    ) -> Self

    Parameters

    result

    The Bool resul value

EUDCC Content Type

  • Has vaccination content ValidationRule

    Declaration

    Swift

    static var isVaccination: `Self` { get }
  • Has test content ValidationRule

    Declaration

    Swift

    static var isTest: `Self` { get }
  • Has recover content ValidationRule

    Declaration

    Swift

    static var isRecovery: `Self` { get }

EUDCC Vaccination

  • Has received all vaccination doses

    Declaration

    Swift

    static var isVaccinationComplete: `Self` { get }
  • Vaccination can be considered as fully immunized

    Declaration

    Swift

    static func isFullyImmunized(
        minimumDaysPast: Int = 15,
        using calendar: Calendar = .current
    ) -> Self

    Parameters

    minimumDaysPast

    The amount of minimum days past since the last vaccination. Default value 15

    calendar

    The Calendar that should be used. Default value .current

  • Validates if the vaccination expired by comparing if the current Date is greater than the date of vaccination added by the maximumDaysSinceVaccinationDate

    Declaration

    Swift

    static func isVaccinationExpired(
        maximumDaysSinceVaccinationDate: Int = 365,
        using calendar: Calendar = .current
    ) -> Self

    Parameters

    maximumDaysSinceVaccinationDate

    The maximum days since date of vaccination. Default value 365

    calendar

    The Calendar. Default value .current

  • Validates if EUDCC contains a Vaccination and the VaccineMedicinalProduct value is contained in the WellKnownValueenumeration

    Declaration

    Swift

    static var isWellKnownVaccineMedicinalProduct: `Self` { get }
  • Validates if the VaccineMedicinalProduct is contained in the given Sequence of VaccineMedicinalProduct WellKnownValues

    Declaration

    Swift

    static func vaccineMedicinalProductIsOneOf<Vaccines: Sequence>(
        _ validVaccineMedicinalProducts: Vaccines
    ) -> Self where Vaccines.Element == EUDCC.Vaccination.VaccineMedicinalProduct.WellKnownValue

    Parameters

    validVaccineMedicinalProducts

    The VaccineMedicinalProduct WellKnownValue Sequence

EUDCC Test

  • TestResult of Test is positive

    Declaration

    Swift

    static var isTestedPositive: `Self` { get }
  • TestResult of Test is negative

    Declaration

    Swift

    static var isTestedNegative: `Self` { get }
  • Is Test valid

    Declaration

    Swift

    static func isTestValid(
        maximumHoursPast: @escaping (EUDCC.Test.TestType.WellKnownValue) -> Int = { $0 == .pcr ? 72 : 48 },
        using calendar: Calendar = .current
    ) -> Self

    Parameters

    maximumHoursPast

    The maximum hours past since date of sample collection. Default value PCR: 72 | RAPID: 48

    calendar

    The Calendar that should be used. Default value .current

EUDCC Recovery

  • Is Recovery valid

    Declaration

    Swift

    static var isRecoveryValid: `Self` { get }

ValidationRule+if

  • Conditionally execute a ValidationRule

    Declaration

    Swift

    static func `if`(
        _ condition: Self,
        then: Self,
        else: Self
    ) -> Self

    Parameters

    condition

    The ValidationRule that will be evaluated

    then

    The then ValidationRule

    else

    The optional ValidationRule

ValidationRule+Not

  • Performs a logical NOT (!) operation on a ValidationRule

    Declaration

    Swift

    static prefix func ! (
        rule: EUDCC.ValidationRule
    ) -> Self

    Parameters

    rule

    The ValidationRule to negate

ValidationRule+And

  • Performs a logical AND (&&) operation on two ValidationRules

    Declaration

    Swift

    static func && (
        lhs: Self,
        rhs: Self
    ) -> Self

    Parameters

    lhs

    The left-hand side of the operation

    rhs

    The right-hand side of the operation

ValidationRule+Or

  • Performs a logical OR (||) operation on two ValidationRules

    Declaration

    Swift

    static func || (
        lhs: Self,
        rhs: Self
    ) -> Self

    Parameters

    lhs

    The left-hand side of the operation

    rhs

    The right-hand side of the operation

Tag

Default

  • The default EUDCC.ValidationRule

    Declaration

    Swift

    static var `default`: `Self` { get }

Equatable

  • Returns a Boolean value indicating whether two values are equal.

    Declaration

    Swift

    public static func == (
        lhs: Self,
        rhs: Self
    ) -> Bool

    Parameters

    lhs

    A value to compare.

    rhs

    Another value to compare.

Hashable

  • Hashes the essential components of this value by feeding them into the given hasher.

    Declaration

    Swift

    public func hash(
        into hasher: inout Hasher
    )

    Parameters

    hasher

    The hasher to use when combining the components of this instance.