@tellescope/validation 1.3.36 → 1.3.40
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 +29 -1
- package/lib/cjs/validation.d.ts.map +1 -1
- package/lib/cjs/validation.js +52 -1
- package/lib/cjs/validation.js.map +1 -1
- package/lib/esm/validation.d.ts +29 -1
- package/lib/esm/validation.d.ts.map +1 -1
- package/lib/esm/validation.js +50 -0
- package/lib/esm/validation.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/src/validation.ts +64 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tellescope/validation",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.40",
|
|
4
4
|
"description": "Input validation functions for server, client, and schema definition",
|
|
5
5
|
"main": "./lib/cjs/validation.js",
|
|
6
6
|
"module": "./lib/esm/validation.js",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/tellescope-os/tellescope#readme",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@tellescope/constants": "^1.3.
|
|
27
|
-
"@tellescope/types-client": "^1.3.
|
|
28
|
-
"@tellescope/types-models": "^1.3.
|
|
26
|
+
"@tellescope/constants": "^1.3.40",
|
|
27
|
+
"@tellescope/types-client": "^1.3.40",
|
|
28
|
+
"@tellescope/types-models": "^1.3.40",
|
|
29
29
|
"@tellescope/types-utilities": "^1.3.20",
|
|
30
|
-
"@tellescope/utilities": "^1.3.
|
|
30
|
+
"@tellescope/utilities": "^1.3.40",
|
|
31
31
|
"validator": "^13.5.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
@@ -44,6 +44,6 @@
|
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "5b9a87e9daf8b38a7e177bf6910618d91d42c042",
|
|
48
48
|
"composite": true
|
|
49
49
|
}
|
package/src/validation.ts
CHANGED
|
@@ -124,8 +124,14 @@ import {
|
|
|
124
124
|
BlockContentH2,
|
|
125
125
|
PortalSettings,
|
|
126
126
|
BlockContentPDF,
|
|
127
|
+
DatabaseRecordFieldType,
|
|
128
|
+
DatabaseRecordFields,
|
|
129
|
+
DatabaseRecordValues,
|
|
130
|
+
DatabaseRecordField,
|
|
131
|
+
OrganizationAccess,
|
|
127
132
|
} from "@tellescope/types-models"
|
|
128
133
|
import {
|
|
134
|
+
DatabaseRecord,
|
|
129
135
|
UserDisplayInfo,
|
|
130
136
|
} from "@tellescope/types-client"
|
|
131
137
|
|
|
@@ -1679,4 +1685,61 @@ export const BLOCK_TYPES = Object.keys(_BLOCK_TYPES) as BlockType[]
|
|
|
1679
1685
|
export const blockTypeValidator = exactMatchValidator<BlockType>(BLOCK_TYPES)
|
|
1680
1686
|
export const is_block_type = (type: any): type is BlockType => BLOCK_TYPES.includes(type)
|
|
1681
1687
|
|
|
1682
|
-
export const blocksValidator = listValidatorEmptyOk(blockValidator())
|
|
1688
|
+
export const blocksValidator = listValidatorEmptyOk(blockValidator())
|
|
1689
|
+
|
|
1690
|
+
|
|
1691
|
+
const _DATABASE_RECORD_FIELD_TYPES: { [K in DatabaseRecordFieldType]: any } = {
|
|
1692
|
+
"string-long": '',
|
|
1693
|
+
number: '',
|
|
1694
|
+
string: '',
|
|
1695
|
+
}
|
|
1696
|
+
export const DATABASE_RECORD_FIELD_TYPES = Object.keys(_DATABASE_RECORD_FIELD_TYPES) as DatabaseRecordFieldType[]
|
|
1697
|
+
export const databaseRecordFieldTypeValidator = exactMatchValidator<DatabaseRecordFieldType>(DATABASE_RECORD_FIELD_TYPES)
|
|
1698
|
+
export const is_database_record_field_type = (type: any): type is DatabaseRecordFieldType => DATABASE_RECORD_FIELD_TYPES.includes(type)
|
|
1699
|
+
|
|
1700
|
+
// structure in this way to support potential differences in the future, like options which apply to only specific types
|
|
1701
|
+
// export const databaseFieldValidator = orValidator<{ [K in DatabaseRecordFieldType]: DatabaseRecordFields[K] } >({
|
|
1702
|
+
// string: objectValidator<DatabaseRecordFields['string']>({
|
|
1703
|
+
// type: exactMatchValidator(['string'])(),
|
|
1704
|
+
// label: stringValidator250(),
|
|
1705
|
+
// })(),
|
|
1706
|
+
// 'string-long': objectValidator<DatabaseRecordFields['string-long']>({
|
|
1707
|
+
// type: exactMatchValidator(['string-long'])(),
|
|
1708
|
+
// label: stringValidator250(),
|
|
1709
|
+
// })(),
|
|
1710
|
+
// 'number': objectValidator<DatabaseRecordFields['number']>({
|
|
1711
|
+
// type: exactMatchValidator(['number'])(),
|
|
1712
|
+
// label: stringValidator250(),
|
|
1713
|
+
// })(),
|
|
1714
|
+
// })
|
|
1715
|
+
|
|
1716
|
+
// structure as above instead if need unique label or additional config based on type
|
|
1717
|
+
export const databaseFieldValidator = objectValidator<DatabaseRecordField>({
|
|
1718
|
+
type: databaseRecordFieldTypeValidator(),
|
|
1719
|
+
label: stringValidator250(),
|
|
1720
|
+
})
|
|
1721
|
+
export const databaseFieldsValidator = listValidator(databaseFieldValidator())
|
|
1722
|
+
|
|
1723
|
+
|
|
1724
|
+
export const databaseRecordValueValidator = orValidator<{ [K in DatabaseRecordFieldType]: DatabaseRecordValues[K] } >({
|
|
1725
|
+
string: objectValidator<DatabaseRecordValues['string']>({
|
|
1726
|
+
type: exactMatchValidator(['string'])(),
|
|
1727
|
+
value: stringValidator1000(),
|
|
1728
|
+
})(),
|
|
1729
|
+
'string-long': objectValidator<DatabaseRecordValues['string-long']>({
|
|
1730
|
+
type: exactMatchValidator(['string-long'])(),
|
|
1731
|
+
value: stringValidator5000(),
|
|
1732
|
+
})(),
|
|
1733
|
+
'number': objectValidator<DatabaseRecordValues['number']>({
|
|
1734
|
+
type: exactMatchValidator(['number'])(),
|
|
1735
|
+
value: numberValidator(),
|
|
1736
|
+
})(),
|
|
1737
|
+
})
|
|
1738
|
+
export const databaseRecordValuesValidator = listValidator(databaseRecordValueValidator())
|
|
1739
|
+
|
|
1740
|
+
export const organizationAccessValidator = objectValidator<OrganizationAccess>({
|
|
1741
|
+
create: booleanValidator({ isOptional: true }),
|
|
1742
|
+
update: booleanValidator({ isOptional: true }),
|
|
1743
|
+
read: booleanValidator({ isOptional: true }),
|
|
1744
|
+
delete: booleanValidator({ isOptional: true }),
|
|
1745
|
+
})
|