Change documents routes; fix #416

This commit is contained in:
qdequele 2020-01-02 12:24:29 +01:00
parent a5c5df0290
commit f0590d3301
No known key found for this signature in database
GPG key ID: B3F0A000EBF11745
4 changed files with 24 additions and 8 deletions

View file

@ -23,7 +23,13 @@ pub fn value_to_string(value: &Value) -> Option<String> {
Value::Null => None,
Value::Bool(_) => None,
Value::Number(value) => Some(value.to_string()),
Value::String(value) => Some(value.to_string()),
Value::String(value) => {
if value.chars().all(|x| x.is_ascii_alphanumeric() || x == '-' || x == '_') {
Some(value.to_string())
} else {
None
}
},
Value::Array(_) => None,
Value::Object(_) => None,
}

View file

@ -55,7 +55,7 @@ impl fmt::Display for SerializerError {
f.write_str("serialized document does not have an id according to the schema")
}
SerializerError::InvalidDocumentIdType => {
f.write_str("document identifier can only be of type string or number")
f.write_str("document identifier can only be of type number or string (A-Z, a-z, 0-9, -_)")
}
SerializerError::Zlmdb(e) => write!(f, "heed related error: {}", e),
SerializerError::SerdeJson(e) => write!(f, "serde json error: {}", e),