ripex 0.3.0

Multi-language structural parsing and fact extraction.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// ripex-lang-test: JS validation — regex, arrow predicates.
/** @param {string} s */
export function isEmail(s) {
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s);
}

/** @param {{ name?: string, email: string } | null | undefined} user */
export function validateUser(user) {
  if (!user?.name) throw new Error('name required');
  if (!isEmail(user.email)) throw new Error('bad email');
  return true;
}

/** @param {unknown} input */
export function sanitize(input) {
  return String(input).trim().toLowerCase();
}