0
# String Checking
1
2
String-specific validation including case checking, content analysis, and format validation.
3
4
## Capabilities
5
6
### Case Validation
7
8
#### Uppercase Check
9
10
Checks if the given string is all uppercase.
11
12
```javascript { .api }
13
/**
14
* Checks if the given string is UPPERCASE
15
* @param value - String to check
16
* @returns True if string is all uppercase
17
* Interfaces: not, all, any
18
*/
19
function upperCase(value: string): boolean;
20
```
21
22
**Usage Example:**
23
24
```javascript
25
is.upperCase('YEAP'); // true
26
is.upperCase('nope'); // false
27
is.not.upperCase('Nope'); // true
28
is.all.upperCase('YEAP', 'nope'); // false
29
is.any.upperCase('YEAP', 'nope'); // true
30
```
31
32
#### Lowercase Check
33
34
Checks if the given string is all lowercase.
35
36
```javascript { .api }
37
/**
38
* Checks if the given string is lowercase
39
* @param value - String to check
40
* @returns True if string is all lowercase
41
* Interfaces: not, all, any
42
*/
43
function lowerCase(value: string): boolean;
44
```
45
46
**Usage Example:**
47
48
```javascript
49
is.lowerCase('yeap'); // true
50
is.lowerCase('NOPE'); // false
51
is.not.lowerCase('Nope'); // true
52
is.all.lowerCase('yeap', 'NOPE'); // false
53
is.any.lowerCase('yeap', 'NOPE'); // true
54
```
55
56
#### Capitalized Check
57
58
Checks if the given string is capitalized (each word starts with uppercase).
59
60
```javascript { .api }
61
/**
62
* Checks if the given string is capitalized
63
* @param value - String to check
64
* @returns True if string is capitalized
65
* Interfaces: not, all, any
66
*/
67
function capitalized(value: string): boolean;
68
```
69
70
**Usage Example:**
71
72
```javascript
73
is.capitalized('Yeap'); // true
74
is.capitalized('nope'); // false
75
is.not.capitalized('nope not capitalized'); // true
76
is.all.capitalized('Yeap', 'All', 'Capitalized'); // true
77
is.any.capitalized('Yeap', 'some', 'Capitalized'); // true
78
```
79
80
### Content Analysis
81
82
#### Include Check
83
84
Checks if the given string contains a substring.
85
86
```javascript { .api }
87
/**
88
* Checks if the given string contains a substring
89
* @param string - String to search in
90
* @param target - Substring to search for
91
* @returns True if string contains target
92
* Interfaces: not
93
*/
94
function include(string: string, target: string): boolean;
95
```
96
97
**Usage Example:**
98
99
```javascript
100
is.include('Some text goes here', 'text'); // true
101
is.include('test', 'text'); // false
102
is.not.include('test', 'text'); // true
103
```
104
105
#### Start With Check
106
107
Checks if the given string starts with a substring.
108
109
```javascript { .api }
110
/**
111
* Checks if the given string starts with substring
112
* @param string - String to check
113
* @param target - Substring to check for at start
114
* @returns True if string starts with target
115
* Interfaces: not
116
*/
117
function startWith(string: string, target: string): boolean;
118
```
119
120
**Usage Example:**
121
122
```javascript
123
is.startWith('yeap', 'ye'); // true
124
is.startWith('nope', 'ye'); // false
125
is.not.startWith('nope not that', 'not'); // true
126
```
127
128
#### End With Check
129
130
Checks if the given string ends with a substring.
131
132
```javascript { .api }
133
/**
134
* Checks if the given string ends with substring
135
* @param string - String to check
136
* @param target - Substring to check for at end
137
* @returns True if string ends with target
138
* Interfaces: not
139
*/
140
function endWith(string: string, target: string): boolean;
141
```
142
143
**Usage Example:**
144
145
```javascript
146
is.endWith('yeap', 'ap'); // true
147
is.endWith('nope', 'no'); // false
148
is.not.endWith('nope not that', 'not'); // true
149
is.endWith('yeap that one', 'one'); // true
150
```
151
152
### Pattern Analysis
153
154
#### Palindrome Check
155
156
Checks if the given string is a palindrome (reads the same forwards and backwards).
157
158
```javascript { .api }
159
/**
160
* Checks if the given string is palindrome
161
* @param value - String to check
162
* @returns True if string is palindrome
163
* Interfaces: not, all, any
164
*/
165
function palindrome(value: string): boolean;
166
```
167
168
**Usage Example:**
169
170
```javascript
171
is.palindrome('testset'); // true
172
is.palindrome('A man, a plan, a canal - Panama!'); // true
173
is.palindrome('nope'); // false
174
is.not.palindrome('nope not palindrome'); // true
175
is.all.palindrome('testset', 'tt'); // true
176
is.any.palindrome('Yeap', 'some', 'testset'); // true
177
```