pub fn validate_claim_presence(
        &self,
        options: ClaimPresenceOptions,
    ) -> Result<(), ValidationError> {
        use crate::Presence::Required;

        let mut missing_claims: Vec<&str> = vec![];

        if options.expiry == Required && self.expiry.is_none() {
            missing_claims.push("exp");
        }

        if options.not_before == Required && self.not_before.is_none() {
            missing_claims.push("nbf");
        }

        if options.issued_at == Required && self.issued_at.is_none() {
            missing_claims.push("iat");
        }

        if options.audience == Required && self.audience.is_none() {
            missing_claims.push("aud");
        }

        if options.issuer == Required && self.issuer.is_none() {
            missing_claims.push("iss");
        }

        if options.subject == Required && self.subject.is_none() {
            missing_claims.push("sub");
        }

        if options.id == Required && self.id.is_none() {
            missing_claims.push("jti");
        }

        if missing_claims.is_empty() {
            Ok(())
        } else {
            Err(ValidationError::MissingRequiredClaims(
                missing_claims.into_iter().map(|v| v.into()).collect(),
            ))
        }
    }
/// Validates that the token contains the claims defined as required
Validates that the token contains the claims defined as required
Validates that the token contains the claims defined as required
pub fn validate_claim_presence(
        &self,
        options: ClaimPresenceOptions,
    ) -> Result<(), ValidationError> {
        use crate::Presence::Required;
        let mut missing_claims: Vec<&str> = vec![];
        if options.expiry == Required && self.expiry.is_none() {
            missing_claims.push("exp");
        }
        if options.not_before == Required && self.not_before.is_none() {
            missing_claims.push("nbf");
        }
        if options.issued_at == Required && self.issued_at.is_none() {
            missing_claims.push("iat");
        }
        if options.audience == Required && self.audience.is_none() {
            missing_claims.push("aud");
        }
        if options.issuer == Required && self.issuer.is_none() {
            missing_claims.push("iss");
        }
        if options.subject == Required && self.subject.is_none() {
            missing_claims.push("sub");
        }
        if options.id == Required && self.id.is_none() {
            missing_claims.push("jti");
        }
        if missing_claims.is_empty() {
            Ok(())
        } else {
            Err(ValidationError::MissingRequiredClaims(
                missing_claims.into_iter().map(|v| v.into()).collect(),
            ))
        }
    }
pub fn validate_claim_presence ( & self , options : ClaimPresenceOptions , ) -> Result < ( ) , ValidationError > { use crate :: Presence :: Required ; let mut missing_claims : Vec < & str > = vec ! [ ] ; if options . expiry == Required && self . expiry . is_none ( ) { missing_claims . push ( " " ) ; } if options . not_before == Required && self . not_before . is_none ( ) { missing_claims . push ( " " ) ; } if options . issued_at == Required && self . issued_at . is_none ( ) { missing_claims . push ( " " ) ; } if options . audience == Required && self . audience . is_none ( ) { missing_claims . push ( " " ) ; } if options . issuer == Required && self . issuer . is_none ( ) { missing_claims . push ( " " ) ; } if options . subject == Required && self . subject . is_none ( ) { missing_claims . push ( " " ) ; } if options . id == Required && self . id . is_none ( ) { missing_claims . push ( " " ) ; } if missing_claims . is_empty ( ) { Ok ( ( ) ) } else { Err ( ValidationError :: MissingRequiredClaims ( missing_claims . into_iter ( ) . map ( | v | v . into ( ) ) . collect ( ) , ) ) } }
Validates that the token contains the claims defined as required
Validates that the token contains the claims defined as required
&self
options
ClaimPresenceOptions
&self
options
ClaimPresenceOptions