identity_credential/validator/
options.rs

1// Copyright 2020-2023 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4use serde::Deserialize;
5use serde::Serialize;
6
7/// Controls validation behaviour when checking whether or not a credential has been revoked by its
8/// [`credentialStatus`](https://www.w3.org/TR/vc-data-model/#status).
9#[derive(Debug, Clone, Copy, PartialEq, Eq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr, Default)]
10#[repr(u8)]
11pub enum StatusCheck {
12  /// Validate the status if supported, reject any unsupported
13  /// [`credentialStatus`](https://www.w3.org/TR/vc-data-model/#status) types.
14  ///
15  /// Only `RevocationBitmap2022` is currently supported.
16  ///
17  /// This is the default.
18  #[default]
19  Strict = 0,
20  /// Validate the status if supported, skip any unsupported
21  /// [`credentialStatus`](https://www.w3.org/TR/vc-data-model/#status) types.
22  SkipUnsupported = 1,
23  /// Skip all status checks.
24  SkipAll = 2,
25}
26
27/// Declares how credential subjects must relate to the presentation holder during validation.
28///
29/// See also the [Subject-Holder Relationship](https://www.w3.org/TR/vc-data-model/#subject-holder-relationships) section of the specification.
30// Need to use serde_repr to make this work with duck typed interfaces in the Wasm bindings.
31#[derive(Debug, Clone, Copy, serde_repr::Serialize_repr, serde_repr::Deserialize_repr, Default)]
32#[repr(u8)]
33pub enum SubjectHolderRelationship {
34  /// The holder must always match the subject on all credentials, regardless of their [`nonTransferable`](https://www.w3.org/TR/vc-data-model/#nontransferable-property) property.
35  /// This is the variant returned by [Self::default](Self::default()) and the default used in
36  /// [`crate::validator::JwtPresentationValidationOptions`].
37  #[default]
38  AlwaysSubject = 0,
39  /// The holder must match the subject only for credentials where the [`nonTransferable`](https://www.w3.org/TR/vc-data-model/#nontransferable-property) property is `true`.
40  SubjectOnNonTransferable = 1,
41  /// Declares that the subject is not required to have any kind of relationship to the holder.
42  Any = 2,
43}
44
45/// Declares when validation should return if an error occurs.
46#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
47pub enum FailFast {
48  /// Return all errors that occur during validation.
49  AllErrors,
50  /// Return after the first error occurs.
51  FirstError,
52}