mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-25 19:45:05 +08:00
Make comparison simpler, add IndexUid error details similarly
This commit is contained in:
parent
ec815fa368
commit
e098cc8320
@ -74,7 +74,8 @@ impl Display for IndexUidFormatError {
|
|||||||
f,
|
f,
|
||||||
"invalid index uid `{}`, the uid must be an integer \
|
"invalid index uid `{}`, the uid must be an integer \
|
||||||
or a string containing only alphanumeric characters \
|
or a string containing only alphanumeric characters \
|
||||||
a-z A-Z 0-9, hyphens - and underscores _.",
|
a-z A-Z 0-9, hyphens - and underscores _, \
|
||||||
|
and can not be more than 400 bytes.",
|
||||||
self.invalid_uid,
|
self.invalid_uid,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,8 @@ impl Display for IndexUidFormatError {
|
|||||||
f,
|
f,
|
||||||
"invalid index uid `{}`, the uid must be an integer \
|
"invalid index uid `{}`, the uid must be an integer \
|
||||||
or a string containing only alphanumeric characters \
|
or a string containing only alphanumeric characters \
|
||||||
a-z A-Z 0-9, hyphens - and underscores _.",
|
a-z A-Z 0-9, hyphens - and underscores _, \
|
||||||
|
and can not be more than 400 bytes.",
|
||||||
self.invalid_uid,
|
self.invalid_uid,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -150,13 +150,13 @@ fn starts_with(selector: &str, key: &str) -> bool {
|
|||||||
// FIXME: move to a DocumentId struct
|
// FIXME: move to a DocumentId struct
|
||||||
|
|
||||||
fn validate_document_id(document_id: &str) -> Option<&str> {
|
fn validate_document_id(document_id: &str) -> Option<&str> {
|
||||||
if !document_id.is_empty()
|
if document_id.is_empty()
|
||||||
&& document_id.len() <= 512
|
|| document_id.len() > 512
|
||||||
&& document_id.chars().all(|c| matches!(c, 'a'..='z' | 'A'..='Z' | '0'..='9' | '-' | '_'))
|
|| !document_id.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_')
|
||||||
{
|
{
|
||||||
Some(document_id)
|
|
||||||
} else {
|
|
||||||
None
|
None
|
||||||
|
} else {
|
||||||
|
Some(document_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user