IsString(value, [minLength], [maxLength]) Last updated: 08. Nov 2023

Validates that a variable is a string with atleast one or more characters (as specified).

Parameters

Name Type Description
value object Value to validate
minLength (optional) number The required number of characters to validate string with.
Default is 1 if not specified.
maxLength (optional) number The maximum number of characters to validate string with.
Default is unlimited if not specified.

Returns

True if value is a string with the specified minimum required length, otherwise false.

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
let text = "testing";

if (docly.isString(text, 2)) write("String is 2 chars or more!\r");
if (docly.isString(text, 5)) write("String is 5 chars or more!\r");
if (docly.isString(text, 8)) write("String is 8 chars or more!\r");

if (!docly.isString(text, 1, 3)) write("String is not between 1 and 3 chars!\r");

Output

The JS code above produces the output shown below:
String is 2 chars or more!
String is 5 chars or more!
String is not between 1 and 3 chars!