@@ -68,7 +68,9 @@ pub struct VulnerabilityReferences(pub Vec<VulnerabilityReference>);
6868impl Validate for VulnerabilityReferences {
6969 fn validate_version ( & self , version : SpecVersion ) -> ValidationResult {
7070 ValidationContext :: new ( )
71- . add_list ( "inner" , & self . 0 , |reference| reference. validate_version ( version) )
71+ . add_list ( "inner" , & self . 0 , |reference| {
72+ reference. validate_version ( version)
73+ } )
7274 . into ( )
7375 }
7476}
@@ -78,6 +80,7 @@ mod test {
7880 use crate :: {
7981 external_models:: { normalized_string:: NormalizedString , uri:: Uri } ,
8082 models:: vulnerability_source:: VulnerabilitySource ,
83+ validation,
8184 } ;
8285
8386 use super :: * ;
@@ -108,56 +111,33 @@ mod test {
108111 } ] )
109112 . validate ( ) ;
110113
111- /*
112114 assert_eq ! (
113115 validation_result,
114- ValidationResult::Failed {
115- reasons: vec![
116- FailureReason {
117- message:
116+ validation:: list(
117+ "inner" ,
118+ [ (
119+ 0 ,
120+ vec![
121+ validation:: field(
122+ "id" ,
118123 "NormalizedString contains invalid characters \\ r \\ n \\ t or \\ r\\ n"
119- .to_string(),
120- context: ValidationContext(vec![
121- ValidationPathComponent::Array { index: 0 },
122- ValidationPathComponent::Struct {
123- struct_name: "VulnerabilityReference".to_string(),
124- field_name: "id".to_string()
125- },
126- ])
127- },
128- FailureReason {
129- message:
130- "NormalizedString contains invalid characters \\r \\n \\t or \\r\\n"
131- .to_string(),
132- context: ValidationContext(vec![
133- ValidationPathComponent::Array { index: 0 },
134- ValidationPathComponent::Struct {
135- struct_name: "VulnerabilityReference".to_string(),
136- field_name: "vulnerability_source".to_string()
137- },
138- ValidationPathComponent::Struct {
139- struct_name: "VulnerabilitySource".to_string(),
140- field_name: "name".to_string()
141- },
142- ])
143- },
144- FailureReason {
145- message: "Uri does not conform to RFC 3986".to_string(),
146- context: ValidationContext(vec![
147- ValidationPathComponent::Array { index: 0 },
148- ValidationPathComponent::Struct {
149- struct_name: "VulnerabilityReference".to_string(),
150- field_name: "vulnerability_source".to_string()
151- },
152- ValidationPathComponent::Struct {
153- struct_name: "VulnerabilitySource".to_string(),
154- field_name: "url".to_string()
155- },
156- ])
157- },
158- ]
159- }
124+ ) ,
125+ validation:: r#struct(
126+ "vulnerability_source" ,
127+ vec![
128+ validation:: field(
129+ "name" ,
130+ "NormalizedString contains invalid characters \\ r \\ n \\ t or \\ r\\ n"
131+ ) ,
132+ validation:: field(
133+ "url" ,
134+ "Uri does not conform to RFC 3986"
135+ )
136+ ]
137+ ) ,
138+ ]
139+ ) ]
140+ )
160141 ) ;
161- */
162142 }
163143}
0 commit comments