diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2022-01-18 19:45:09 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2022-01-18 19:45:09 -0400 |
commit | 859b8fb20525b44a94ab5072405c6c9d6df4da5b (patch) | |
tree | b2e56fb20931d6f8702157e7a4cb113e39faab3c /src/thing/structures.js | |
parent | b10d00e4f4cf191ed9cb914052422db4363de349 (diff) |
initial working changes for big data restructure
Diffstat (limited to 'src/thing/structures.js')
-rw-r--r-- | src/thing/structures.js | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/src/thing/structures.js b/src/thing/structures.js index 89c9bd39..364ba149 100644 --- a/src/thing/structures.js +++ b/src/thing/structures.js @@ -1,32 +1 @@ // Generic structure utilities common across various Thing types. - -export function validateDirectory(directory) { - if (typeof directory !== 'string') - throw new TypeError(`Expected a string, got ${directory}`); - - if (directory.length === 0) - throw new TypeError(`Expected directory to be non-zero length`); - - if (directory.match(/[^a-zA-Z0-9\-]/)) - throw new TypeError(`Expected only letters, numbers, and dash, got "${directory}"`); - - return true; -} - -export function validateReference(type = '') { - return ref => { - if (typeof ref !== 'string') - throw new TypeError(`Expected a string, got ${ref}`); - - if (type) { - if (!ref.includes(':')) - throw new TypeError(`Expected ref to begin with "${type}:", but no type specified (ref: ${ref})`); - - const typePart = ref.split(':')[0]; - if (typePart !== type) - throw new TypeError(`Expected ref to begin with "${type}:", got "${typePart}:" (ref: ${ref})`); - } - - return true; - }; -} |