MCPcopy
hub / github.com/deepstreamIO/deepstream.io / validate

Function validate

src/services/permission/valve/path-parser.ts:15–35  ·  view source on GitHub ↗
(path: string)

Source from the content-addressed store, hash-verified

13 * @returns {String|Boolean} true if path is valid, string error message if not
14 */
15export const validate = (path: string): string | boolean => {
16 if (typeof path !== 'string') {
17 return 'path must be a string'
18 }
19
20 if (path.length === 0) {
21 return 'path can\'t be empty'
22 }
23
24 if (path[0] === '/') {
25 return 'path can\'t start with /'
26 }
27
28 const invalidVariableNames = path.match(INVALID_VARIABLE_REGEXP)
29
30 if (invalidVariableNames !== null) {
31 return `invalid variable name ${invalidVariableNames[0]}`
32 }
33
34 return true
35}
36
37/**
38 * Parses a path and returns a regexp matcher with capture groups for

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected