use crate::value::FieldValue;
pub fn is_in(value: &str, list: &[&str]) -> bool {
list.contains(&value)
}
pub fn is_not_in(value: &str, list: &[&str]) -> bool {
!list.contains(&value)
}
pub fn is_same(a: &FieldValue, b: &FieldValue) -> bool {
a == b
}
pub fn is_different(a: &FieldValue, b: &FieldValue) -> bool {
a != b
}
pub fn is_gt(a: &FieldValue, b: &FieldValue) -> bool {
a.partial_cmp(b)
.is_some_and(|o| o == std::cmp::Ordering::Greater)
}
pub fn is_gte(a: &FieldValue, b: &FieldValue) -> bool {
a.partial_cmp(b)
.is_some_and(|o| o != std::cmp::Ordering::Less)
}
pub fn is_lt(a: &FieldValue, b: &FieldValue) -> bool {
a.partial_cmp(b)
.is_some_and(|o| o == std::cmp::Ordering::Less)
}
pub fn is_lte(a: &FieldValue, b: &FieldValue) -> bool {
a.partial_cmp(b)
.is_some_and(|o| o != std::cmp::Ordering::Greater)
}
pub fn is_in_array(value: &FieldValue, array: &FieldValue) -> bool {
if let FieldValue::List(items) = array {
items.contains(value)
} else {
false
}
}
pub fn is_distinct(values: &FieldValue) -> bool {
if let FieldValue::List(items) = values {
for i in 0..items.len() {
for j in (i + 1)..items.len() {
if items[i] == items[j] {
return false;
}
}
}
true
} else {
true
}
}