Class Validations

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.Validations
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.128.0 (build 749b9a9)", date="2026-04-29T18:45:13.509Z") @Stability(Stable) public class Validations extends software.amazon.jsii.JsiiObject
Manages validations for CDK constructs.

Example:

 App myApp;
 IPolicyValidationPlugin plugin;
 Validations.of(myApp).addPlugins(plugin);
 
  • Nested Class Summary

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Metadata key used to store acknowledged rules on construct nodes.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Validations(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    Validations(software.amazon.jsii.JsiiObjectRef objRef)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Acknowledge one or more rules, suppressing them from validation output.
    void
    addError(String id, String message)
    Adds an error metadata entry to this construct.
    void
    Register one or more validation plugins that will be executed during synthesis.
    void
    addWarning(String id, String message)
    Adds a warning metadata entry to this construct that can be acknowledged.
    of(software.constructs.IConstruct scope)
    Returns the Validations for the given construct scope.

    Methods inherited from class software.amazon.jsii.JsiiObject

    jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • Field Details

    • ACKNOWLEDGED_RULES_METADATA_KEY

      @Stability(Stable) public static final String ACKNOWLEDGED_RULES_METADATA_KEY
      Metadata key used to store acknowledged rules on construct nodes.

      Plugin authors can read this metadata to build audit trails from acknowledgments recorded via acknowledge().

  • Constructor Details

    • Validations

      protected Validations(software.amazon.jsii.JsiiObjectRef objRef)
    • Validations

      protected Validations(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
  • Method Details

    • of

      @Stability(Stable) @NotNull public static Validations of(@NotNull software.constructs.IConstruct scope)
      Returns the Validations for the given construct scope.

      Parameters:
      scope - any construct. This parameter is required.
    • acknowledge

      @Stability(Stable) public void acknowledge(@NotNull Acknowledgment... rules)
      Acknowledge one or more rules, suppressing them from validation output.

      Acknowledgments are recorded to construct metadata so that downstream plugins (e.g. CDK Nag) can read them for audit trails.

      Currently only annotation warnings can be suppressed. Annotation errors are not yet acknowledgeable.

      If an ID has no well-known prefix, it is assumed to be an annotation rule for backwards compatibility.

      Parameters:
      rules - the rules to acknowledge. This parameter is required.
    • addError

      @Stability(Stable) public void addError(@NotNull String id, @NotNull String message)
      Adds an error metadata entry to this construct.

      Synthesis will be interrupted when errors are reported.

      Note: Annotation errors are not currently acknowledgeable. The ID is recorded for identification purposes but acknowledge() will not suppress errors added via this method.

      Parameters:
      id - unique identifier for the error. This parameter is required.
      message - the error message. This parameter is required.
    • addPlugins

      @Stability(Stable) public void addPlugins(@NotNull IPolicyValidationPlugin... plugins)
      Register one or more validation plugins that will be executed during synthesis.

      Plugins can only be registered within a Stage or App scope. If any plugin reports a violation, synthesis will be interrupted and the report displayed to the user.

      Parameters:
      plugins - the validation plugins to add. This parameter is required.
    • addWarning

      @Stability(Stable) public void addWarning(@NotNull String id, @NotNull String message)
      Adds a warning metadata entry to this construct that can be acknowledged.

      The CLI will display the warning when an app is synthesized, or fail if run in --strict mode.

      The ID will be stored with the annotation prefix (e.g. annotation::MyWarning). Use this prefixed ID when calling acknowledge() to suppress the warning.

      Parameters:
      id - unique identifier for the warning, used for acknowledgement. This parameter is required.
      message - the warning message. This parameter is required.