@@ -467,7 +467,7 @@ pub(super) fn reserved_claim(claim: &str) -> bool {
467467}
468468
469469#[ derive( Debug , thiserror:: Error ) ]
470- #[ error( "dev.yaml {field} {reason}" ) ]
470+ #[ error( "dev.yaml {field}: {reason} Next: {remedy }" ) ]
471471pub ( super ) struct SemanticRefusal {
472472 field : String ,
473473 reason : String ,
@@ -492,7 +492,7 @@ pub(super) fn require(
492492 Ok ( ( ) )
493493}
494494
495- fn refuse < T > ( field : & str , reason : & str , remedy : & str ) -> SemanticResult < T > {
495+ pub ( super ) fn refuse < T > ( field : & str , reason : & str , remedy : & str ) -> SemanticResult < T > {
496496 Err ( SemanticRefusal {
497497 field : field. to_owned ( ) ,
498498 reason : reason. to_owned ( ) ,
@@ -543,23 +543,30 @@ fn read_plan(root: &Path) -> Result<Decoded<Plan>> {
543543 . decode :: < Plan > ( & bytes, & Expect :: one ( & FORMAT ) ) ?)
544544}
545545
546+ fn refusal_report ( decoded : & Decoded < Plan > , refusal : & SemanticRefusal ) -> Report {
547+ let diagnostic = decoded. document . diagnostic_at_value (
548+ Severity :: Error ,
549+ "rstack.dev.invalid-plan" ,
550+ & refusal. field ,
551+ & refusal. reason ,
552+ & refusal. remedy ,
553+ ) ;
554+ decoded. document . report_with ( [ diagnostic] )
555+ }
556+
546557fn validate_plan ( root : & Path , decoded : & Decoded < Plan > ) -> Result < ( ) > {
547- if let Err ( refusal) = decoded. value . validate ( root) {
548- let diagnostic = decoded. document . diagnostic_at_value (
549- Severity :: Error ,
550- "rstack.dev.invalid-plan" ,
551- & refusal. field ,
552- & refusal. reason ,
553- & refusal. remedy ,
554- ) ;
555- return Err ( decoded. document . report_with ( [ diagnostic] ) . into ( ) ) ;
556- }
557- Ok ( ( ) )
558+ decoded
559+ . value
560+ . validate ( root)
561+ . map_err ( |refusal| refusal_report ( decoded, & refusal) . into ( ) )
558562}
559563
560564pub ( crate ) fn check ( root : & Path ) -> Result < Report > {
561565 let decoded = read_plan ( root) ?;
562566 validate_plan ( root, & decoded) ?;
567+ if let Err ( refusal) = super :: products:: schema_people ( root, & decoded. value , false ) {
568+ return Err ( refusal_report ( & decoded, & refusal) . into ( ) ) ;
569+ }
563570 Ok ( decoded. document . report_with ( Vec :: new ( ) ) )
564571}
565572
0 commit comments