summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Van Doorn <vandoorn.nick@gmail.com>2018-12-09 23:07:07 -0800
committerNick Van Doorn <vandoorn.nick@gmail.com>2018-12-09 23:07:07 -0800
commit44d5639cab3a95c10428819696761cccdfcb88f0 (patch)
treeebc6a09c06c1d51ed0b958fb3dd0850039ef78da
parent28895cc0f195aae8169fa85ff57c5b48095f79ed (diff)
(broken) Implement config validation
-rw-r--r--src/models/config.model.ts25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/models/config.model.ts b/src/models/config.model.ts
index 910f436..3e2d08d 100644
--- a/src/models/config.model.ts
+++ b/src/models/config.model.ts
@@ -1,3 +1,4 @@
+import * as v from 'class-validator'
/**
* Interface used to model the current configuration.
* This gets injected using a Context instance.
@@ -6,16 +7,33 @@
* some visual interface to make this a user friendly tool
* but for now a JSON file will suffice.
*/
-export interface Config {
+export class Config {
// how many clients can be on a given adapter
// when testing it. A negative value represents "any", and
// 0 actually represents 0 clients.
+ @v.IsInt()
maxClientsForTest: number
+
+ @v.IsInt()
testPeriod: number // how many seconds between each test
+
+ @v.IsString()
adapter: string // default to "actiontec-t3200m"
+
+ @v.IsString()
+ adapterUrl: string // TODO ?? Sane default
+
+ @v.ArrayNotEmpty()
testServices: string[] // default to ["fast", "ookla"]
- serviceSpec: string // default to "telus-victoria-75"
+
+ @v.IsOptional()
+ @v.IsString()
+ serviceSpec?: string // default to "telus-victoria-75"
+
+ @v.ArrayNotEmpty()
reporters: string[] // default to ["firebase"]
+
+ @v.IsInt()
nTestSamples: number // number of required samples when testing
reportFilename?: string
@@ -26,3 +44,6 @@ export interface Config {
sheetsSheetName?: string
}
+
+// TODO for some reason this doesn't work ;=;
+export const validateConfig = (inst: Config) => v.validate(inst)