-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
The 3 modifiers share a lot of code, there might be a way to simplify this a bit, since they're all more or less specializations over a validator with multiple possible validations, and only really differ in the number of validations that can fail/pass. The TryFrom<Yaml> implementations for instance are almost identical, only differing in naming.
There's also some duplication in the PropertyType structure which will most likely also just increase over time as more modifiers are added:
yaml-validator/yaml-validator/src/lib.rs
Lines 119 to 153 in 7c09d93
| if yaml | |
| .lookup("not", "hash", Option::from) | |
| .map(Option::from) | |
| .or_else(optional(None))? | |
| .is_some() | |
| { | |
| return Ok(PropertyType::Not(SchemaNot::try_from(yaml)?)); | |
| } | |
| if yaml | |
| .lookup("oneOf", "hash", Option::from) | |
| .map(Option::from) | |
| .or_else(optional(None))? | |
| .is_some() | |
| { | |
| return Ok(PropertyType::OneOf(SchemaOneOf::try_from(yaml)?)); | |
| } | |
| if yaml | |
| .lookup("allOf", "hash", Option::from) | |
| .map(Option::from) | |
| .or_else(optional(None))? | |
| .is_some() | |
| { | |
| return Ok(PropertyType::AllOf(SchemaAllOf::try_from(yaml)?)); | |
| } | |
| if yaml | |
| .lookup("anyOf", "hash", Option::from) | |
| .map(Option::from) | |
| .or_else(optional(None))? | |
| .is_some() | |
| { | |
| return Ok(PropertyType::AnyOf(SchemaAnyOf::try_from(yaml)?)); | |
| } |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels