Skip to content

Commit fba1aff

Browse files
committed
Fix function documentation
1 parent b65f381 commit fba1aff

File tree

1 file changed

+10
-6
lines changed
  • quickwit-doc-mapper/src/default_doc_mapper

1 file changed

+10
-6
lines changed

quickwit-doc-mapper/src/default_doc_mapper/mod.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,18 @@ pub use self::default_mapper::{DefaultDocMapper, DefaultDocMapperBuilder, SortBy
2929
pub use self::field_mapping_entry::{DocParsingError, FieldMappingEntry};
3030
pub use self::field_mapping_type::FieldMappingType;
3131

32-
/// Regular expression representing the restriction on a valid field name.
32+
/// Regular expression validating a field mapping name.
3333
pub const FIELD_MAPPING_NAME_PATTERN: &str = r#"^[_a-zA-Z][_\.\-a-zA-Z0-9]{0,254}$"#;
3434

35-
/// Validator for a potential `field_mapping_name`.
36-
/// Returns true if the name can be use for a field mapping name.
35+
/// Validates a field mapping name.
36+
/// Returns `Ok(())` if the name can be used for a field mapping. Does not check for reserved field
37+
/// mapping names such as `_source`.
3738
///
38-
/// A field mapping name must start by a letter `[a-zA-Z]`.
39-
/// The other characters can be any alphanumic character `[a-ZA-Z0-9]` or `_`, `.`, `-`.
39+
/// A field mapping name:
40+
/// - may only contain uppercase and lowercase ASCII letters `[a-zA-Z]`, digits `[0-9]`, hyphens
41+
/// `-`, periods `.`, and underscores `_`;
42+
/// - must start with an uppercase or lowercase ASCII letter `[a-zA-Z]`, or an underscore `_`;
43+
/// - must not be longer than 255 characters.
4044
pub fn validate_field_mapping_name(field_mapping_name: &str) -> anyhow::Result<()> {
4145
static FIELD_MAPPING_NAME_PTN: Lazy<Regex> =
4246
Lazy::new(|| Regex::new(FIELD_MAPPING_NAME_PATTERN).unwrap());
@@ -57,7 +61,7 @@ pub fn validate_field_mapping_name(field_mapping_name: &str) -> anyhow::Result<(
5761
if !first_char.is_ascii_alphabetic() && first_char != '_' {
5862
bail!(
5963
"Field name `{}` is invalid. Field names must start with an uppercase or lowercase \
60-
ASCII letter or an underscore `_`.",
64+
ASCII letter, or an underscore `_`.",
6165
field_mapping_name
6266
)
6367
}

0 commit comments

Comments
 (0)