From 1001b77968970cbf92a3a82aea87ecfa957c89c9 Mon Sep 17 00:00:00 2001 From: Thierry de Pauw Date: Sun, 25 Aug 2024 15:50:04 +0200 Subject: [PATCH] Update documentation with policy validation (#6) --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index 463fe97..4100b67 100644 --- a/README.md +++ b/README.md @@ -149,3 +149,39 @@ Supports different principals. // "Principal" : "*" const wildcardPrincipal = new WildcardPrincipal(); ``` + +Validate a policy document. + +```typescript + // validate any policy + // when valid returns an empty list + // when invalid returns a list of errors + const errors = policy.validate(); + if (errors) { + throw errors; + } + + // validate an IAM policy document + const errors = policy.validate(PolicyType.IAM); + if (errors) { + throw errors; + } + + //validate a KMS key policy document. + const errors = policy.validate(PolicyType.KMS); + if (errors) { + throw errors; + } + + //validate an S3 bucket policy document. + const errors = policy.validate(PolicyType.S3); + if (errors) { + throw errors; + } + + //validate a SecretsManager secret policy document. + const errors = policy.validate(PolicyType.SecretsManager); + if (errors) { + throw errors; + } +```