MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / saslprepString

Function saslprepString

framework/framework/validator.ts:77–89  ·  view source on GitHub ↗
(regex?: RegExp, cb?: (i: string) => boolean, convert?: (i: string) => T)

Source from the content-addressed store, hash-verified

75 },
76] as [(v) => string, (v) => boolean];
77const saslprepString = <T = string>(regex?: RegExp, cb?: (i: string) => boolean, convert?: (i: string) => T) => [
78 convert || ((v) => saslprep(v.toString().trim())),
79 (v) => {
80 try {
81 const res = saslprep(v.toString().trim());
82 if (regex && !regex.test(res)) return false;
83 if (cb && !cb(res)) return false;
84 return !!res.length;
85 } catch (e) {
86 return false;
87 }
88 },
89] as [(v) => string, (v) => boolean];
90
91export const Types = {
92 Content: [(v) => v.toString().trim(), (v) => v?.toString()?.trim() && v.toString().trim().length < 65536],

Callers 1

validator.tsFile · 0.85

Calls 1

cbFunction · 0.50

Tested by

no test coverage detected