Skip to content

Commit 9b1802f

Browse files
committed
a few new functions
1 parent c36601d commit 9b1802f

6 files changed

Lines changed: 648 additions & 588 deletions

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ The following functions check whether a given argument satisfies a certain const
160160
* **`ValueIsJSONString (Value:unknown):boolean`**<br>returns `true` if the given `Value` is a string which can be parsed with `JSON.parse` - or `false` otherwise
161161
* **`ValueIsBase64 (Value:unknown):boolean`**<br>returns `true` if the given `Value` is a non-empty, correctly padded Base64-encoded string (using the standard alphabet) - or an empty string - and `false` otherwise
162162
* **`ValueIsHexString (Value:unknown):boolean`**<br>returns `true` if the given `Value` is a non-empty string consisting of hexadecimal digits only - or `false` otherwise
163+
* **`ValueIsIdentifier (Value:unknown):boolean`**<br>returns `true` if the given `Value` is a string containing a syntactically valid JavaScript identifier (checked against the full Unicode grammar, i.e., `ID_Start` followed by `ID_Continue` characters, incl. `$`, `_`, ZWNJ and ZWJ - reserved words are *not* rejected) - or `false` otherwise
163164

164165
### Argument Validation Functions ###
165166

@@ -213,7 +214,7 @@ For the sake of clarity, however, only the first "flavour" (namely `allowXXX`) i
213214
* **`allowPhoneNumber (Description:string, Argument:any):string|null|undefined`**<br>checks if the given `Argument` (if it exists) is a string containing a syntactically plausible phone number in a common national or international notation (see `ValueIsPhoneNumber`). If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`
214215
* **`allowE164PhoneNumber (Description:string, Argument:any):string|null|undefined`**<br>checks if the given `Argument` (if it exists) is a string containing a phone number in the canonical E.164 format (see `ValueIsE164PhoneNumber`). If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`<br>&nbsp;<br>
215216
* **`allowBigInt`**, **`allowSymbol`**, **`allowMap`**, **`allowSet`**, **`allowTypedArray`**, **`allowArrayBuffer`**<br>validate the given `Argument` using `ValueIsBigInt`, `ValueIsSymbol`, `ValueIsMap`, `ValueIsSet`, `ValueIsTypedArray` or `ValueIsArrayBuffer`, resp., and behave like any other `allowXXX` function described above (incl. their `allowedXXX`, `expectXXX` and `expectedXXX` flavours)
216-
* **`allowUUID`**, **`allowISODate`**, **`allowISOTimestamp`**, **`allowIPv4Address`**, **`allowIPv6Address`**, **`allowHostName`**, **`allowPortNumber`**, **`allowJSONString`**, **`allowBase64`**, **`allowHexString`**<br>validate the given `Argument` using the corresponding `ValueIsXXX` classifier and behave like any other `allowXXX` function described above (incl. their `allowedXXX`, `expectXXX` and `expectedXXX` flavours)
217+
* **`allowUUID`**, **`allowISODate`**, **`allowISOTimestamp`**, **`allowIPv4Address`**, **`allowIPv6Address`**, **`allowHostName`**, **`allowPortNumber`**, **`allowJSONString`**, **`allowBase64`**, **`allowHexString`**, **`allowIdentifier`**<br>validate the given `Argument` using the corresponding `ValueIsXXX` classifier and behave like any other `allowXXX` function described above (incl. their `allowedXXX`, `expectXXX` and `expectedXXX` flavours)
217218

218219
### Utility Functions ###
219220

‎dist/javascript-interface-library.d.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ export declare const allowedHexString: (Description: string, Argument: any) => s
5353

5454
export declare const allowedHostName: (Description: string, Argument: any) => string | null | undefined;
5555

56+
export declare const allowedIdentifier: (Description: string, Argument: any) => string | null | undefined;
57+
5658
export declare const allowedInstanceOf: typeof allowInstanceOf;
5759

5860
export declare const allowedInteger: (Description: string, Argument: any) => number | null | undefined;
@@ -139,6 +141,8 @@ export declare const allowHexString: (Description: string, Argument: any) => str
139141

140142
export declare const allowHostName: (Description: string, Argument: any) => string | null | undefined;
141143

144+
export declare const allowIdentifier: (Description: string, Argument: any) => string | null | undefined;
145+
142146
/**** allow[ed]InstanceOf ****/
143147
export declare function allowInstanceOf(Description: string, Argument: any, constructor: Function, Expectation: string): any | null | undefined;
144148

@@ -430,6 +434,8 @@ export declare const expectedHexString: (Description: string, Argument: any) =>
430434

431435
export declare const expectedHostName: (Description: string, Argument: any) => string;
432436

437+
export declare const expectedIdentifier: (Description: string, Argument: any) => string;
438+
433439
export declare const expectedInstanceOf: typeof expectInstanceOf;
434440

435441
export declare const expectedInteger: (Description: string, Argument: any) => number;
@@ -518,6 +524,8 @@ export declare const expectHexString: (Description: string, Argument: any) => st
518524

519525
export declare const expectHostName: (Description: string, Argument: any) => string;
520526

527+
export declare const expectIdentifier: (Description: string, Argument: any) => string;
528+
521529
/**** expect[ed]InstanceOf ****/
522530
export declare function expectInstanceOf(Description: string, Argument: any, constructor: Function, Expectation: string): any;
523531

@@ -731,6 +739,8 @@ export declare function ValueIsHexString(Value: unknown): Value is string;
731739

732740
export declare function ValueIsHostName(Value: unknown): Value is string;
733741

742+
export declare function ValueIsIdentifier(Value: unknown): Value is string;
743+
734744
/**** ValueIsInstanceOf ****/
735745
export declare function ValueIsInstanceOf<T>(Value: unknown, Constructor: abstract new (...ArgumentList: any[]) => T): Value is T;
736746

0 commit comments

Comments
 (0)