or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

collection-validation.mdconfiguration.mddate-time.mdenvironment-detection.mdindex.mdnumeric-operations.mdpattern-matching.mdpresence-checking.mdstring-checking.mdtype-checking.md
tile.json

configuration.mddocs/

0

# Configuration

1

2

Library configuration and utility functions for customization and namespace management.

3

4

## Capabilities

5

6

### Namespace Management

7

8

#### Set Namespace

9

10

Changes the namespace of the library to prevent name collisions with other libraries that might use the global `is` variable.

11

12

```javascript { .api }

13

/**

14

* Change namespace of library to prevent name collisions

15

* @returns New reference to the is object, while restoring previous global 'is'

16

*/

17

function setNamespace(): typeof is;

18

```

19

20

**Usage Example:**

21

22

```javascript

23

// Save reference before other libraries override 'is'

24

const customName = is.setNamespace();

25

26

// Now 'is' refers to whatever was there before,

27

// and customName refers to is.js

28

customName.odd(3); // true

29

customName.string('test'); // true

30

31

// The global 'is' has been restored to its previous value

32

```

33

34

### Regular Expression Customization

35

36

#### Set RegExp

37

38

Override built-in regular expressions with custom patterns for specific validation needs.

39

40

```javascript { .api }

41

/**

42

* Override RegExps if you think they suck

43

* @param regexp - New regular expression pattern

44

* @param name - Name of the regexp to override

45

*/

46

function setRegexp(regexp: RegExp, name: string): void;

47

```

48

49

**Usage Example:**

50

51

```javascript

52

// Original URL validation

53

is.url('https://www.duckduckgo.com'); // true

54

55

// Override the URL regex with a custom pattern

56

is.setRegexp(/quack/, 'url');

57

58

// Now the URL function uses the new pattern

59

is.url('quack'); // true

60

is.url('https://www.duckduckgo.com'); // false (no longer matches)

61

```

62

63

**Available RegExp Names:**

64

65

The following built-in regular expressions can be overridden:

66

67

- `'affirmative'` - Affirmative responses (yes, true, ok, etc.)

68

- `'alphaNumeric'` - Alphanumeric characters

69

- `'caPostalCode'` - Canadian postal codes

70

- `'creditCard'` - Credit card numbers

71

- `'dateString'` - Date string formats

72

- `'email'` - Email addresses

73

- `'eppPhone'` - EPP phone numbers

74

- `'hexadecimal'` - Hexadecimal values

75

- `'hexColor'` - Hex color codes

76

- `'ipv4'` - IPv4 addresses

77

- `'ipv6'` - IPv6 addresses

78

- `'nanpPhone'` - North American phone numbers

79

- `'socialSecurityNumber'` - US Social Security Numbers

80

- `'timeString'` - Time string formats

81

- `'ukPostCode'` - UK postal codes

82

- `'url'` - URL formats

83

- `'usZipCode'` - US ZIP codes