@prismatic-io/spectral 7.0.7-pre → 7.0.8-pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/util.d.ts +3 -0
- package/dist/util.js +29 -0
- package/package.json +1 -1
package/dist/util.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ declare const _default: {
|
|
|
31
31
|
toBufferDataPayload: (value: unknown) => DataPayload;
|
|
32
32
|
isData: (value: unknown) => boolean;
|
|
33
33
|
toData: (value: unknown) => DataPayload;
|
|
34
|
+
isString: (value: unknown) => value is string;
|
|
34
35
|
toString: (value: unknown, defaultValue?: string) => string;
|
|
35
36
|
keyValPairListToObject: <TValue = unknown>(kvpList: KeyValuePair<unknown>[], valueConverter?: ((value: unknown) => TValue) | undefined) => Record<string, TValue>;
|
|
36
37
|
isJSON: (value: string) => boolean;
|
|
@@ -42,6 +43,8 @@ declare const _default: {
|
|
|
42
43
|
toObjectFieldMap: (value: unknown) => ObjectFieldMap;
|
|
43
44
|
isJSONForm: (value: unknown) => value is JSONForm;
|
|
44
45
|
toJSONForm: (value: unknown) => JSONForm;
|
|
46
|
+
isPicklist: (value: unknown) => boolean;
|
|
47
|
+
isSchedule: (value: unknown) => boolean;
|
|
45
48
|
};
|
|
46
49
|
docs: {
|
|
47
50
|
formatJsonExample: (input: unknown) => string;
|
package/dist/util.js
CHANGED
|
@@ -280,6 +280,25 @@ const toDate = (value) => {
|
|
|
280
280
|
* @returns This function returns true if `value` is a valid URL, and false otherwise.
|
|
281
281
|
*/
|
|
282
282
|
const isUrl = (value) => (0, valid_url_1.isWebUri)(value) !== undefined;
|
|
283
|
+
/**
|
|
284
|
+
* This function checks if value is a valid picklist.
|
|
285
|
+
*
|
|
286
|
+
* - `util.types.isPicklist(["value", new String("value")])` will return `true`.
|
|
287
|
+
*
|
|
288
|
+
* @param value The variable to test.
|
|
289
|
+
* @returns This function returns true if `value` is a valid picklist.
|
|
290
|
+
*/
|
|
291
|
+
const isPicklist = (value) => Array.isArray(value) && value.every(isString);
|
|
292
|
+
/**
|
|
293
|
+
* This function checks if value is a valid schedule.
|
|
294
|
+
*
|
|
295
|
+
* - `util.types.isSchedule({value: "00 00 * * 2,3"})` will return `true`.
|
|
296
|
+
* - `util.types.isSchedule({value: "00 00 * * 2,3", scheduleType: "week", timeZone: "America/Chicago"})` will return `true`.
|
|
297
|
+
*
|
|
298
|
+
* @param value The variable to test.
|
|
299
|
+
* @returns This function returns true if `value` is a valid schedule.
|
|
300
|
+
*/
|
|
301
|
+
const isSchedule = (value) => isObjectWithTruthyKeys(value, ["value"]);
|
|
283
302
|
/**
|
|
284
303
|
* This function helps to transform key-value lists to objects.
|
|
285
304
|
* This is useful for transforming inputs that are key-value collections into objects.
|
|
@@ -373,6 +392,13 @@ const toData = (value) => toBufferDataPayload(value);
|
|
|
373
392
|
* @returns This function returns a code block that can be used for documentation.
|
|
374
393
|
*/
|
|
375
394
|
const formatJsonExample = (input) => ["```json", JSON.stringify(input, undefined, 2), "```"].join("\n");
|
|
395
|
+
/**
|
|
396
|
+
* This function checks if value is a string.
|
|
397
|
+
* `util.types.isString("value")` and `util.types.isString(new String("value"))` return true.
|
|
398
|
+
* @param value The variable to test.
|
|
399
|
+
* @returns This function returns true or false, depending on if `value` is a string.
|
|
400
|
+
*/
|
|
401
|
+
const isString = (value) => typeof value === "string" || value instanceof String;
|
|
376
402
|
/**
|
|
377
403
|
* This function converts a `value` to a string.
|
|
378
404
|
* If `value` is undefined or an empty string, an optional `defaultValue` can be returned.
|
|
@@ -445,6 +471,7 @@ exports.default = {
|
|
|
445
471
|
toBufferDataPayload,
|
|
446
472
|
isData,
|
|
447
473
|
toData,
|
|
474
|
+
isString,
|
|
448
475
|
toString,
|
|
449
476
|
keyValPairListToObject,
|
|
450
477
|
isJSON,
|
|
@@ -456,6 +483,8 @@ exports.default = {
|
|
|
456
483
|
toObjectFieldMap,
|
|
457
484
|
isJSONForm,
|
|
458
485
|
toJSONForm,
|
|
486
|
+
isPicklist,
|
|
487
|
+
isSchedule,
|
|
459
488
|
},
|
|
460
489
|
docs: {
|
|
461
490
|
formatJsonExample,
|