mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-13 15:13:07 +00:00
12 lines
442 B
TypeScript
12 lines
442 B
TypeScript
const CONTACT_SEARCH_MIN_LENGTH = 2
|
|
|
|
export const normalizeContactSearchQuery = (raw: string) => {
|
|
const trimmed = raw.trim().slice(0, 120)
|
|
const digits = trimmed.replace(/\D/g, '')
|
|
return { trimmed, digits }
|
|
}
|
|
|
|
export const isContactSearchQueryReady = (raw: string) => {
|
|
const { trimmed, digits } = normalizeContactSearchQuery(raw)
|
|
return trimmed.length >= CONTACT_SEARCH_MIN_LENGTH || digits.length >= CONTACT_SEARCH_MIN_LENGTH
|
|
}
|