pub fn validate(&self, ast_schema: &ast::SchemaAst) -> Result<ValidatedDatamodel, Diagnostics> {
        let mut diagnostics = Diagnostics::new();

        // Phase 0 is parsing.
        // Phase 1 is source block loading.

        // Phase 2: Prechecks.
        if let Err(mut err) = precheck::Precheck::precheck(&ast_schema) {
            diagnostics.append(&mut err);
        }

        // Early return so that the validator does not have to deal with invalid schemas
        if diagnostics.has_errors() {
            return Err(diagnostics);
        }

        // Phase 3: Lift AST to DML.
        let mut schema = match self.lifter.lift(ast_schema) {
            Err(mut err) => {
                // Cannot continue on lifter error.
                diagnostics.append(&mut err);
                return Err(diagnostics);
            }
            Ok(schema) => schema,
        };

        // Phase 4: Validation
        if let Err(mut err) = self.validator.validate(ast_schema, &mut schema) {
            diagnostics.append(&mut err);
        }

        // Early return so that the standardiser does not have to deal with invalid schemas
        if diagnostics.has_errors() {
            return Err(diagnostics);
        }

        // TODO: Move consistency stuff into different module.
        // Phase 5: Consistency fixes. These don't fail.
        if let Err(mut err) = self.standardiser.standardise(ast_schema, &mut schema) {
            diagnostics.append(&mut err);
        }

        // Early return so that the post validation does not have to deal with invalid schemas
        if diagnostics.has_errors() {
            return Err(diagnostics);
        }

        // Phase 6: Post Standardisation Validation
        if let Err(mut err) = self.validator.post_standardisation_validate(ast_schema, &mut schema) {
            diagnostics.append(&mut err);
        }

        if diagnostics.has_errors() {
            Err(diagnostics)
        } else {
            Ok(ValidatedDatamodel {
                subject: schema,
                warnings: diagnostics.warnings,
            })
        }
    }
/// Validates an AST semantically and promotes it to a datamodel/schema.
///
/// This method will attempt to
/// * Resolve all attributes
/// * Recursively evaluate all functions
/// * Perform string interpolation
/// * Resolve and check default values
/// * Resolve and check all field types
Validates an AST semantically and promotes it to a datamodel/schema.
This method will attempt to
Resolve all attributes
Recursively evaluate all functions
Perform string interpolation
Resolve and check default values
Resolve and check all field types
Validates an AST semantically and promotes it to a datamodel / schema . This method will attempt to Resolve all attributes Recursively evaluate all functions Perform string interpolation Resolve and check default values Resolve and check all field types
pub fn validate(&self, ast_schema: &ast::SchemaAst) -> Result<ValidatedDatamodel, Diagnostics> {
        let mut diagnostics = Diagnostics::new();
        // Phase 0 is parsing.
        // Phase 1 is source block loading.
        // Phase 2: Prechecks.
        if let Err(mut err) = precheck::Precheck::precheck(&ast_schema) {
            diagnostics.append(&mut err);
        }
        // Early return so that the validator does not have to deal with invalid schemas
        if diagnostics.has_errors() {
            return Err(diagnostics);
        }
        // Phase 3: Lift AST to DML.
        let mut schema = match self.lifter.lift(ast_schema) {
            Err(mut err) => {
                // Cannot continue on lifter error.
                diagnostics.append(&mut err);
                return Err(diagnostics);
            }
            Ok(schema) => schema,
        };
        // Phase 4: Validation
        if let Err(mut err) = self.validator.validate(ast_schema, &mut schema) {
            diagnostics.append(&mut err);
        }
        // Early return so that the standardiser does not have to deal with invalid schemas
        if diagnostics.has_errors() {
            return Err(diagnostics);
        }
        // TODO: Move consistency stuff into different module.
        // Phase 5: Consistency fixes. These don't fail.
        if let Err(mut err) = self.standardiser.standardise(ast_schema, &mut schema) {
            diagnostics.append(&mut err);
        }
        // Early return so that the post validation does not have to deal with invalid schemas
        if diagnostics.has_errors() {
            return Err(diagnostics);
        }
        // Phase 6: Post Standardisation Validation
        if let Err(mut err) = self.validator.post_standardisation_validate(ast_schema, &mut schema) {
            diagnostics.append(&mut err);
        }
        if diagnostics.has_errors() {
            Err(diagnostics)
        } else {
            Ok(ValidatedDatamodel {
                subject: schema,
                warnings: diagnostics.warnings,
            })
        }
    }
pub fn validate ( & self , ast_schema : & ast :: SchemaAst ) -> Result < ValidatedDatamodel , Diagnostics > { let mut diagnostics = Diagnostics :: new ( ) ; // Phase 0 is parsing. // Phase 1 is source block loading. // Phase 2: Prechecks. if let Err ( mut err ) = precheck :: Precheck :: precheck ( & ast_schema ) { diagnostics . append ( & mut err ) ; } // Early return so that the validator does not have to deal with invalid schemas if diagnostics . has_errors ( ) { return Err ( diagnostics ) ; } // Phase 3: Lift AST to DML. let mut schema = match self . lifter . lift ( ast_schema ) { Err ( mut err ) => { // Cannot continue on lifter error. diagnostics . append ( & mut err ) ; return Err ( diagnostics ) ; } Ok ( schema ) => schema , } ; // Phase 4: Validation if let Err ( mut err ) = self . validator . validate ( ast_schema , & mut schema ) { diagnostics . append ( & mut err ) ; } // Early return so that the standardiser does not have to deal with invalid schemas if diagnostics . has_errors ( ) { return Err ( diagnostics ) ; } // TODO: Move consistency stuff into different module. // Phase 5: Consistency fixes. These don't fail. if let Err ( mut err ) = self . standardiser . standardise ( ast_schema , & mut schema ) { diagnostics . append ( & mut err ) ; } // Early return so that the post validation does not have to deal with invalid schemas if diagnostics . has_errors ( ) { return Err ( diagnostics ) ; } // Phase 6: Post Standardisation Validation if let Err ( mut err ) = self . validator . post_standardisation_validate ( ast_schema , & mut schema ) { diagnostics . append ( & mut err ) ; } if diagnostics . has_errors ( ) { Err ( diagnostics ) } else { Ok ( ValidatedDatamodel { subject : schema , warnings : diagnostics . warnings , } ) } }
Validates an AST semantically and promotes it to a datamodel/schema.
Validates an AST semantically and promotes it to a datamodel / schema .
&self
ast_schema
&ast::SchemaAst
&self
ast_schema
&ast::SchemaAst