From 6e9aa4989377598d83d062a3d0f1fa49e192ffa3 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Mon, 6 Jan 2025 15:08:07 +0100 Subject: [PATCH] add valid_facet_value utility function --- crates/milli/src/update/index_documents/helpers/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/milli/src/update/index_documents/helpers/mod.rs b/crates/milli/src/update/index_documents/helpers/mod.rs index c188e324d..195d12455 100644 --- a/crates/milli/src/update/index_documents/helpers/mod.rs +++ b/crates/milli/src/update/index_documents/helpers/mod.rs @@ -16,6 +16,10 @@ pub fn valid_lmdb_key(key: impl AsRef<[u8]>) -> bool { key.as_ref().len() <= MAX_WORD_LENGTH * 2 && !key.as_ref().is_empty() } +pub fn valid_facet_value(facet_value: impl AsRef<[u8]>) -> bool { + facet_value.as_ref().len() <= (MAX_WORD_LENGTH * 2) - 3 && !facet_value.as_ref().is_empty() +} + /// Divides one slice into two at an index, returns `None` if mid is out of bounds. pub fn try_split_at(slice: &[T], mid: usize) -> Option<(&[T], &[T])> { if mid <= slice.len() {