Skip to main content

SchemaValidator

Struct SchemaValidator 

Source
pub struct SchemaValidator { /* private fields */ }

Implementations§

Source§

impl SchemaValidator

Source

pub fn new( config: SchemaValidatorConfig, ) -> Result<Self, SchemaValidatorConfigError>

Constructs a SchemaValidator from a SchemaValidatorConfig, resolving and applying each additional schema once. The resulting [OverlayCatalog] is stored and accessible via Self::overlay_catalog.

This is the canonical construction path: bindings, the CLI, and library embedders all go through this method. A configured overlay behaves identically no matter which front end supplied it.

For call sites that need no overlay schemas, SchemaValidator::default() provides an infallible, zero-config constructor.

Returns an error when an overlay is malformed.

Source

pub fn try_with_additional_schemas<I, S>( additional_schemas: I, ) -> Result<Self, SchemaOverlayError>
where I: IntoIterator<Item = (S, Value)>, S: AsRef<str>,

Construct a validator whose schema store has additional_schemas merged on top of the bundled schemas.

Each item is a (type_name, schema) pair where schema is an already-parsed CloudFormation resource provider schema (registry JSON, the same shape the build-time schema compiler consumes) and type_name is the resource type it applies to. Overlays are applied in order, so a later overlay sees the result of the earlier ones. The crate::overlay module documents the merge model and its scope limits.

Fails, without building a validator, when an overlay is not a JSON object, carries no type name, nests too deeply, defines a cyclic $ref graph, or would change nothing. An overlay for a type the bundled schemas do not contain is registered as a new type and logged, since that is also what a misspelled type name looks like.

Source

pub fn init_metric(&self) -> &PhaseMetric

Source

pub fn validate( &self, model: &Arc<SemanticModel>, region: Option<&str>, ) -> SchemaValidationResult

Validates every resource. region is the configured AWS region, or None when the caller supplied none - in which case region-scoped checks widen to the union of all regions (a resource type or enum value is flagged only when it is unavailable in every region) rather than assuming a default region.

Source

pub fn enrich_context( &self, diagnostics: &mut [Diagnostic], model: &Arc<SemanticModel>, )

Source

pub fn schema_count(&self) -> usize

Source

pub fn resource_schema_metadata( &self, type_name: &str, ) -> Option<ResourceSchemaMetadata>

Returns the schema fields needed to map request parameters to one CloudFormation resource type, including configured schema overlays.

Source

pub fn has_resource_type(&self, type_name: &str) -> bool

Whether this validator has a bundled or caller-provided schema for a CloudFormation resource type.

Source

pub fn resource_type_names(&self) -> impl Iterator<Item = &str>

Iterates every bundled and caller-provided CloudFormation resource type.

Source

pub fn list_rules(&self) -> Vec<RuleInfo>

Trait Implementations§

Source§

impl Default for SchemaValidator

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.