@tellescope/validation 1.3.13 → 1.3.14
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/lib/cjs/validation.d.ts +26 -1
- package/lib/cjs/validation.d.ts.map +1 -1
- package/lib/cjs/validation.js +60 -2
- package/lib/cjs/validation.js.map +1 -1
- package/lib/esm/validation.d.ts +26 -1
- package/lib/esm/validation.d.ts.map +1 -1
- package/lib/esm/validation.js +57 -1
- package/lib/esm/validation.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/validation.ts +64 -2
package/src/validation.ts
CHANGED
|
@@ -115,6 +115,13 @@ import {
|
|
|
115
115
|
FormResponseAnswerDate,
|
|
116
116
|
FormResponseAnswerRanking,
|
|
117
117
|
FormFieldOptions,
|
|
118
|
+
BlockType,
|
|
119
|
+
Block,
|
|
120
|
+
BlockContentH1,
|
|
121
|
+
BlockContentHTML,
|
|
122
|
+
BlockContentImage,
|
|
123
|
+
BlockContentYoutube,
|
|
124
|
+
BlockContentH2,
|
|
118
125
|
} from "@tellescope/types-models"
|
|
119
126
|
import {
|
|
120
127
|
UserDisplayInfo,
|
|
@@ -323,6 +330,10 @@ export const filterCommandsValidator: EscapeBuilder<FilterType> = (o={}) => buil
|
|
|
323
330
|
if (!is_object(value)) { throw new Error("Expecting object value for FilterType") }
|
|
324
331
|
|
|
325
332
|
if (value._exists && typeof value._exists === 'boolean' ) return { _exists: value._exists }
|
|
333
|
+
if (value._gt && typeof value._gt === 'number' ) return { _gt: value._gt }
|
|
334
|
+
if (value._gte && typeof value._gte === 'number' ) return { _gte: value._gte }
|
|
335
|
+
if (value._lt && typeof value._lt === 'number' ) return { _lt: value._lt }
|
|
336
|
+
if (value._lte && typeof value._gt === 'number' ) return { _gt: value._gt }
|
|
326
337
|
|
|
327
338
|
if (Object.keys(value).find(k => k.startsWith('$'))) { // ignore any $ injections
|
|
328
339
|
throw new Error(`Unknown filter value ${JSON.stringify(value)}`)
|
|
@@ -1202,7 +1213,7 @@ export const chatAttachmentValidator = objectValidator<ChatAttachment>({
|
|
|
1202
1213
|
type: exactMatchValidator<ChatAttachmentType>(['image', 'video', 'file'])(),
|
|
1203
1214
|
secureName: stringValidator250(),
|
|
1204
1215
|
})
|
|
1205
|
-
export const listOfChatAttachmentsValidator =
|
|
1216
|
+
export const listOfChatAttachmentsValidator = listValidatorEmptyOk(chatAttachmentValidator())
|
|
1206
1217
|
|
|
1207
1218
|
export const meetingsListValidator = listValidator(objectValidator<{
|
|
1208
1219
|
id: string,
|
|
@@ -1411,6 +1422,7 @@ export const automationActionValidator = orValidator<{ [K in AutomationActionTyp
|
|
|
1411
1422
|
export const relatedRecordValidator = objectValidator<RelatedRecord>({
|
|
1412
1423
|
type: stringValidator100(),
|
|
1413
1424
|
id: mongoIdStringValidator(),
|
|
1425
|
+
creator: mongoIdStringOptional,
|
|
1414
1426
|
})
|
|
1415
1427
|
export const listOfRelatedRecordsValidator = listValidatorEmptyOk(relatedRecordValidator())
|
|
1416
1428
|
|
|
@@ -1528,4 +1540,54 @@ export const formFieldOptionsValidator = objectValidator<FormFieldOptions>({
|
|
|
1528
1540
|
to: numberValidator({ isOptional: true }),
|
|
1529
1541
|
other: stringValidator250({ isOptional: true }),
|
|
1530
1542
|
radio: booleanValidator({ isOptional: true }),
|
|
1531
|
-
})
|
|
1543
|
+
})
|
|
1544
|
+
|
|
1545
|
+
export const blockValidator = orValidator<{ [K in BlockType]: Block & { type: K } } >({
|
|
1546
|
+
h1: objectValidator<BlockContentH1>({
|
|
1547
|
+
type: exactMatchValidator(['h1'])(),
|
|
1548
|
+
info: objectValidator<BlockContentH1['info']>({
|
|
1549
|
+
text: stringValidator5000({ emptyStringOk: true }),
|
|
1550
|
+
})(),
|
|
1551
|
+
})(),
|
|
1552
|
+
h2: objectValidator<BlockContentH2>({
|
|
1553
|
+
type: exactMatchValidator(['h2'])(),
|
|
1554
|
+
info: objectValidator<BlockContentH1['info']>({
|
|
1555
|
+
text: stringValidator5000({ emptyStringOk: true }),
|
|
1556
|
+
})(),
|
|
1557
|
+
})(),
|
|
1558
|
+
html: objectValidator<BlockContentHTML>({
|
|
1559
|
+
type: exactMatchValidator(['html'])(),
|
|
1560
|
+
info: objectValidator<BlockContentHTML['info']>({
|
|
1561
|
+
html: stringValidator25000({ emptyStringOk: true }),
|
|
1562
|
+
})(),
|
|
1563
|
+
})(),
|
|
1564
|
+
image: objectValidator<BlockContentImage>({
|
|
1565
|
+
type: exactMatchValidator(['image'])(),
|
|
1566
|
+
info: objectValidator<BlockContentImage['info']>({
|
|
1567
|
+
link: stringValidator5000({ emptyStringOk: true }),
|
|
1568
|
+
height: nonNegNumberValidator({ isOptional: true }),
|
|
1569
|
+
width: nonNegNumberValidator({ isOptional: true }),
|
|
1570
|
+
})(),
|
|
1571
|
+
})(),
|
|
1572
|
+
youtube: objectValidator<BlockContentYoutube>({
|
|
1573
|
+
type: exactMatchValidator(['youtube'])(),
|
|
1574
|
+
info: objectValidator<BlockContentYoutube['info']>({
|
|
1575
|
+
link: stringValidator5000({ emptyStringOk: true }),
|
|
1576
|
+
height: nonNegNumberValidator({ isOptional: true }),
|
|
1577
|
+
width: nonNegNumberValidator({ isOptional: true }),
|
|
1578
|
+
})(),
|
|
1579
|
+
})(),
|
|
1580
|
+
})
|
|
1581
|
+
|
|
1582
|
+
const _BLOCK_TYPES: { [K in BlockType]: any } = {
|
|
1583
|
+
h1: '',
|
|
1584
|
+
h2: '',
|
|
1585
|
+
html: '',
|
|
1586
|
+
image: '',
|
|
1587
|
+
youtube: '',
|
|
1588
|
+
}
|
|
1589
|
+
export const BLOCK_TYPES = Object.keys(_BLOCK_TYPES) as BlockType[]
|
|
1590
|
+
export const blockTypeValidator = exactMatchValidator<BlockType>(BLOCK_TYPES)
|
|
1591
|
+
export const is_block_type = (type: any): type is BlockType => BLOCK_TYPES.includes(type)
|
|
1592
|
+
|
|
1593
|
+
export const blocksValidator = listValidatorEmptyOk(blockValidator())
|