Revert "/api/schema.rs: implement Schema::Option"
This reverts commit 0a35462c1e
.
I am not sure this add much value, and the old approach needs
less memory. If we really need single optional values, we can still
implement such Option while keeping the hash based approach...
This commit is contained in:
@ -150,14 +150,9 @@ impl SectionConfig {
|
||||
let mut state = ParseState::BeforeHeader;
|
||||
|
||||
let test_required_properties = |value: &Value, schema: &ObjectSchema| -> Result<(), Error> {
|
||||
for (name, prop_schema) in &schema.properties {
|
||||
match prop_schema.as_ref() {
|
||||
Schema::Option(_) => {},
|
||||
_ => {
|
||||
if value[name] == Value::Null {
|
||||
return Err(format_err!("property '{}' is missing and it is not optional.", name));
|
||||
}
|
||||
}
|
||||
for (name, (optional, _prop_schema)) in &schema.properties {
|
||||
if *optional == false && value[name] == Value::Null {
|
||||
return Err(format_err!("property '{}' is missing and it is not optional.", name));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@ -209,7 +204,7 @@ impl SectionConfig {
|
||||
if let Some((key, value)) = (self.parse_section_content)(line) {
|
||||
//println!("CONTENT: key: {} value: {}", key, value);
|
||||
|
||||
if let Some(prop_schema) = plugin.properties.properties.get::<str>(&key) {
|
||||
if let Some((_optional, prop_schema)) = plugin.properties.properties.get::<str>(&key) {
|
||||
match parse_simple_value(&value, prop_schema) {
|
||||
Ok(value) => {
|
||||
if config[&key] == Value::Null {
|
||||
|
Reference in New Issue
Block a user