-
-
Notifications
You must be signed in to change notification settings - Fork 202
Expand file tree
/
Copy pathcommand-params.ts
More file actions
32 lines (25 loc) · 917 Bytes
/
command-params.ts
File metadata and controls
32 lines (25 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
export class StringCommandParameter implements ICommandParameter {
public mandatory = false;
public errorMessage: string;
constructor(private $injector: IInjector) { }
public async validate(validationValue: string): Promise<boolean> {
if (!validationValue) {
if (this.errorMessage) {
this.$injector.resolve("errors").fail(this.errorMessage);
}
return false;
}
return true;
}
}
$injector.register("stringParameter", StringCommandParameter);
export class StringParameterBuilder implements IStringParameterBuilder {
constructor(private $injector: IInjector) { }
public createMandatoryParameter(errorMsg: string): ICommandParameter {
const commandParameter = new StringCommandParameter(this.$injector);
commandParameter.mandatory = true;
commandParameter.errorMessage = errorMsg;
return commandParameter;
}
}
$injector.register("stringParameterBuilder", StringParameterBuilder);