pub fn descend(
    cfg: &Config,
    instance: &Value,
    schema: &Value,
    instance_ctx: &Context,
    schema_ctx: &Context,
    ref_ctx: &Context,
    errors: &mut ErrorRecorder,
) -> Option<()> {
    match schema {
        Bool(b) => {
            if !*b {
                errors.record_error(ValidationError::new_with_schema_context(
                    "false schema always fails",
                    schema_ctx,
                ))?
            }
        }
        Object(schema_object) => {
            if let (Some(ref_), Some(validator)) =
                (schema_object.get("$ref"), cfg.get_validator("$ref"))
            {
                validator(
                    cfg,
                    instance,
                    ref_,
                    schema_object,
                    instance_ctx,
                    &schema_ctx.push(&"$ref".into()),
                    ref_ctx,
                    errors,
                )?;
            } else {
                for (k, v) in schema_object.iter() {
                    if let Some(validator) = cfg.get_validator(k.as_ref()) {
                        validator(
                            cfg,
                            instance,
                            v,
                            schema_object,
                            instance_ctx,
                            &schema_ctx.push(&k.clone().into()),
                            ref_ctx,
                            errors,
                        )?
                    }
                }
            }
        }
        _ => errors.record_error(ValidationError::new_with_schema_context(
            format!("Invalid schema. Must be Bool or Object, got '{:?}'", schema).as_str(),
            schema_ctx,
        ))?,
    }
    Some(())
}
// The top-level validation function that performs all of the concrete
// validation functions at a given instance/schema pair.
The top-level validation function that performs all of the concrete
validation functions at a given instance/schema pair.
The top - level validation function that performs all of the concrete validation functions at a given instance / schema pair .
pub fn descend(
    cfg: &Config,
    instance: &Value,
    schema: &Value,
    instance_ctx: &Context,
    schema_ctx: &Context,
    ref_ctx: &Context,
    errors: &mut ErrorRecorder,
) -> Option<()> {
    match schema {
        Bool(b) => {
            if !*b {
                errors.record_error(ValidationError::new_with_schema_context(
                    "false schema always fails",
                    schema_ctx,
                ))?
            }
        }
        Object(schema_object) => {
            if let (Some(ref_), Some(validator)) =
                (schema_object.get("$ref"), cfg.get_validator("$ref"))
            {
                validator(
                    cfg,
                    instance,
                    ref_,
                    schema_object,
                    instance_ctx,
                    &schema_ctx.push(&"$ref".into()),
                    ref_ctx,
                    errors,
                )?;
            } else {
                for (k, v) in schema_object.iter() {
                    if let Some(validator) = cfg.get_validator(k.as_ref()) {
                        validator(
                            cfg,
                            instance,
                            v,
                            schema_object,
                            instance_ctx,
                            &schema_ctx.push(&k.clone().into()),
                            ref_ctx,
                            errors,
                        )?
                    }
                }
            }
        }
        _ => errors.record_error(ValidationError::new_with_schema_context(
            format!("Invalid schema. Must be Bool or Object, got '{:?}'", schema).as_str(),
            schema_ctx,
        ))?,
    }
    Some(())
}
pub fn descend ( cfg : & Config , instance : & Value , schema : & Value , instance_ctx : & Context , schema_ctx : & Context , ref_ctx : & Context , errors : & mut ErrorRecorder , ) -> Option < ( ) > { match schema { Bool ( b ) => { if ! * b { errors . record_error ( ValidationError :: new_with_schema_context ( " " , schema_ctx , ) ) ? } } Object ( schema_object ) => { if let ( Some ( ref_ ) , Some ( validator ) ) = ( schema_object . get ( " " ) , cfg . get_validator ( " " ) ) { validator ( cfg , instance , ref_ , schema_object , instance_ctx , & schema_ctx . push ( & " " . into ( ) ) , ref_ctx , errors , ) ? ; } else { for ( k , v ) in schema_object . iter ( ) { if let Some ( validator ) = cfg . get_validator ( k . as_ref ( ) ) { validator ( cfg , instance , v , schema_object , instance_ctx , & schema_ctx . push ( & k . clone ( ) . into ( ) ) , ref_ctx , errors , ) ? } } } } _ => errors . record_error ( ValidationError :: new_with_schema_context ( format ! ( " " schema ) . as_str ( ) , schema_ctx , ) ) ? , } Some ( ( ) ) }
The top-level validation function that performs all of the concrete
validation functions at a given instance/schema pair.
The top - level validation function that performs all of the concrete validation functions at a given instance / schema pair .
cfg
&Config
instance
&Value
schema
&Value
instance_ctx
&Context
schema_ctx
&Context
ref_ctx
&Context
errors
&mut ErrorRecorder
cfg
&Config
instance
&Value
schema
&Value
instance_ctx
&Context
schema_ctx
&Context
ref_ctx
&Context
errors
&mut ErrorRecorder