Skip to content

Commit

Permalink
Endwith dont need to be checked with string literal
Browse files Browse the repository at this point in the history
`//.` and `.` should end in the same way

Also address review comment about `['//.']` -> `"//."`
  • Loading branch information
sravan-s committed Aug 3, 2023
1 parent 1e91e81 commit a5a12f0
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ fn validate_timestamp_field(
timestamp_field_path: &str,
mapping_root_node: &MappingNode,
) -> anyhow::Result<()> {
if timestamp_field_path.starts_with('.') || timestamp_field_path.starts_with(['\\', '.']) {
if timestamp_field_path.starts_with('.') || timestamp_field_path.starts_with("\\.") {
bail!("Timestamp field `{timestamp_field_path}` should not start with a `.`.");
}
if timestamp_field_path.ends_with('.') || timestamp_field_path.ends_with(['\\', '.']) {
if timestamp_field_path.ends_with('.') {
bail!("Timestamp field `{timestamp_field_path}` should not end with a `.`.");
}
let Some(timestamp_field_type) =
Expand Down Expand Up @@ -275,10 +275,10 @@ impl TryFrom<DefaultDocMapperBuilder> for DefaultDocMapper {
/// - if str, the field must use the `raw` tokenizer for indexing.
/// - the field must be indexed.
fn validate_tag(tag_field_name: &str, schema: &Schema) -> Result<(), anyhow::Error> {
if tag_field_name.starts_with('.') || tag_field_name.starts_with(['\\', '.']) {
if tag_field_name.starts_with('.') || tag_field_name.starts_with("\\.") {
bail!("Tag field `{tag_field_name}` should not start with a `.`.");
}
if tag_field_name.ends_with('.') || tag_field_name.ends_with(['\\', '.']) {
if tag_field_name.ends_with('.') {
bail!("Tag field `{tag_field_name}` should not end with a `.`.");
}
let field = schema
Expand Down

0 comments on commit a5a12f0

Please sign in to comment.