A generic type variable Length constrained by the number type, by default of value captured from the supplied length indicates the length of the provided value via the return type and the fixed shape of optional payload parameter of the provided callback function.
Payloadextendsobject=object
The Payload generic type variable constrained by object indicates the type of optional parameter payload of the supplied callback function and payload optional parameter of the isStringLength() function from which it captures its value.
A callback function of ResultCallback type with parameters, the value that has been checked, the result of this check, and payload of generic type variable Payload with optional properties from the provided payload, to handle them before the result return. By default, it uses resultCallback() function.
The payload parameter of the callback function consists of the length property given in parameter of the core function, and it can't be overwritten by the given payload parameter of the core function.
payload?: Payload
An optional object of the generic type variable Payload is assigned to the payload of the given callback function.
Return type
value is StringOfLength<Length, Length, Type>
The return type is a boolean as the result of its statement indicating the value is a generic type StringOfLength that takes generic type variables Min and Max from the generic type variable Length as the length of the supplied value, and generic type variable Type as the type of the provided value.
Returns
The return value is a boolean indicating whether the provided value is a string type or an instance of String of the specified length.
// Example usage.
import { isStringLength } from '@angular-package/type';
const firstName = 'my first name';
// true; The return type `value is StringOfLength<13, 13, string>`
isStringLength(firstName, 13);
// false; The return type `value is StringOfLength<12, 12, string>`
isStringLength(firstName, 12);
// false; The return type `value is StringOfLength<14, 13, string>`
isStringLength(firstName, 14);
// Example usage.
import { isStringLength } from '@angular-package/type';
const firstName = 'my first name';
const firstNameBox = new String(firstName);
// true; The return type `value is StringOfLength<0, 13, string>`
isStringLength(firstNameBox, 13);
// false; The return type `value is StringOfLength<14, 14, string>`
isStringLength(firstNameBox, 14);
// false; The return type `value is StringOfLength<12, 12, string>`
isStringLength(firstNameBox, 12);