@metreeca/core - v0.9.22
    Preparing search index...

    Function optional

    • Makes a validator tolerant of absent values.

      Accepts undefined unconditionally, delegating anything else to the wrapped validator, so an optional property is constrained only when actually present.

      Type Parameters

      • T

        The type of the present value

      Parameters

      • validator: Modal<Validator<T>>

        The validator applied to present values, omitted or disabled to accept any value

      Returns Validator<T | undefined>

      A validator reporting the violations a present value incurs