@terascope/data-mate / function-configs/string/sql-validator-utils
function-configs/string/sql-validator-utils
Variables
EMAIL_SQL_PATTERN
constEMAIL_SQL_PATTERN:string
Defined in: data-mate/src/function-configs/string/sql-validator-utils.ts:29
core-utils' own isEmail pattern, which is not validator.isEmail.
const EmailRegex = /^[A-Z0-9._%+-@]{1,64}@(?:[A-Z0-9-]{1,63}\.){1,8}[A-Z]{2,63}$/i;
export function isEmail(input) { return isString(input) && EmailRegex.test(input); }
It has no lookaround or backreference, so RE2 compiles it.
The i flag is expanded by hand rather than passed to DuckDB. Without the u flag JavaScript's
i uses simple case folding, while RE2 uses full Unicode folding, so [A-Z] with i matches
KELVIN SIGN and LATIN SMALL LETTER LONG S in RE2 but not in JavaScript. Writing [A-Za-z] avoids
case folding entirely, so no guard or UDF fallback is needed.
+-@ is a range (U+002B to U+0040), not three literals, so it also admits ,, ., /, the
digits, :, ;, <, =, > and ?. It is copied as written, and RE2 reads the range the
same way.
ISO_3166_ALPHA2
constISO_3166_ALPHA2: readonlystring[]
Defined in: data-mate/src/function-configs/string/sql-validator-utils.ts:78
validator.isISO31661Alpha2's 249 country codes, generated from its source.
The function is a Set lookup on str.toUpperCase(). core-utils does not pass
userAssignedCodes, so nothing else in it is reachable.
Non-ASCII values keep the UDF. JavaScript's toUpperCase uses full case mapping and can change a
string's length, so 'fi' (LATIN SMALL LIGATURE FI) uppercases to 'FI', a real country code,
where DuckDB's simple mapping leaves it unchanged.
MAC_SQL_PATTERNS
constMAC_SQL_PATTERNS:Record<string,string>
Defined in: data-mate/src/function-configs/string/sql-validator-utils.ts:38
core-utils' macAddressDelimiters, which is not validator.isMACAddress.
There is one fixed regex per delimiter, and 'any' tries each in turn, so no backreference is
needed to keep the separators consistent. space uses JS_WHITESPACE_CLASS because its \s is
JavaScript's.
MIME_SQL_PATTERNS
constMIME_SQL_PATTERNS: readonlystring[]
Defined in: data-mate/src/function-configs/string/sql-validator-utils.ts:60
Functions
matchesAny()
matchesAny(
value,patterns):string
Defined in: data-mate/src/function-configs/string/sql-validator-utils.ts:46
An OR of regexp_matches over several patterns - isMACAddress's any, and isMIMEType.
Parameters
| Parameter | Type |
|---|---|
value | string |
patterns | readonly string[] |
Returns
string