json_model/
error.rs

1use crate::definition::Type;
2use crate::validator::DocumentPath;
3
4use std::collections::HashSet;
5
6use serde_json;
7
8#[derive(Debug)]
9pub enum Error {
10    ParseError(serde_json::Error),
11    InvalidRoot,
12    MissingAttribute {
13        path: DocumentPath,
14        attr: String,
15    },
16    InvalidValue {
17        path: DocumentPath,
18        value: serde_json::Value,
19    },
20    ForbiddenType {
21        path: DocumentPath,
22        typ: Type,
23    },
24    UnrecognizedAttribute {
25        path: DocumentPath,
26        attr: String,
27    },
28    UnknownType {
29        path: DocumentPath,
30        typ: String,
31    },
32    DuplicatePointer {
33        path: DocumentPath,
34        ptr: String,
35    },
36    DuplicateId {
37        path: DocumentPath,
38        id: String,
39    },
40    DuplicateName {
41        path: DocumentPath,
42        name: String,
43    },
44    // TODO: Check duplicate attributes when building attributes, etc.
45    DuplicateAttribute {
46        path: DocumentPath,
47        attr: String,
48    },
49    UndefinedId {
50        path: DocumentPath,
51        id: String,
52    },
53    UnresolvedPointers {
54        target: String,
55        sources: HashSet<String>,
56    },
57}
58
59#[derive(Debug)]
60pub enum ValidationError {
61    UndefinedDefinition,
62    Failure {
63        rule: String,
64        path: Vec<String>,
65        message: String,
66    },
67}