pub fn validate_auto(content: &str) -> ValidationResultExpand description
Auto-detect the YAML format and validate it.
This is the main entry point for one-call validation. It:
- Splits multi-document YAML files (separated by
---) and validates each document independently, merging the results. - Calls
detect_yaml_typeon the parsed content. - Dispatches to the appropriate per-format validator.
The returned ValidationResult is always populated — if parsing
fails, valid is false and errors contains the parse error.
§Example
use devops_validate::validator::validate_auto;
// Valid multi-replica deployment — no errors, but possible warnings
let yaml = r#"
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: app
image: my-app:v1.0.0
"#;
let result = validate_auto(yaml);
assert!(result.valid);
assert_eq!(result.yaml_type.unwrap().to_string(), "K8s Deployment");