1
- use boon:: { Compiler , Schemas } ;
2
- use serde_json:: Value ;
3
1
use std:: fs:: File ;
4
2
use std:: path:: { Component , Path } ;
5
3
use std:: { error:: Error , fmt} ;
6
4
5
+ use boon:: { Compiler , Schemas } ;
6
+ use serde_json:: Value ;
7
7
use wax:: Glob ;
8
8
9
9
pub struct Validator {
@@ -24,15 +24,15 @@ impl fmt::Display for ValidationError {
24
24
write ! ( f, "Missing meta-spec version" )
25
25
}
26
26
}
27
- pub fn new < P : AsRef < Path > > ( dir : P ) -> Result < Validator , Box < dyn Error > > {
28
- let compiler = new_compiler ( dir) ?;
29
- let schemas = Schemas :: new ( ) ;
30
- Ok ( Validator { compiler, schemas } )
31
- }
32
-
33
27
const SCHEMA_BASE : & str = "https://pgxn.org/meta/v" ;
34
28
35
29
impl Validator {
30
+ pub fn new < P : AsRef < Path > > ( dir : P ) -> Result < Validator , Box < dyn Error > > {
31
+ let compiler = new_compiler ( dir) ?;
32
+ let schemas = Schemas :: new ( ) ;
33
+ Ok ( Validator { compiler, schemas } )
34
+ }
35
+
36
36
pub fn validate < ' a > ( & ' a mut self , meta : & ' a Value ) -> Result < bool , Box < dyn Error + ' _ > > {
37
37
let map = meta. as_object ( ) . ok_or ( ValidationError :: UnknownSpec ) ?;
38
38
let version = map
@@ -139,7 +139,7 @@ mod tests {
139
139
fn test_validator ( ) -> Result < ( ) , Box < dyn Error > > {
140
140
let schemas_dir: PathBuf = [ env ! ( "CARGO_MANIFEST_DIR" ) , "schema" ] . iter ( ) . collect ( ) ;
141
141
142
- let mut validator = new ( schemas_dir) ?;
142
+ let mut validator = Validator :: new ( schemas_dir) ?;
143
143
let valid_file: PathBuf = [
144
144
env ! ( "CARGO_MANIFEST_DIR" ) ,
145
145
"tests" ,
0 commit comments