Created
August 28, 2021 19:58
-
-
Save buildmotion/0fc08f20759f8a778b5e99b4edbf9206 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class RulePolicy implements IRuleComponent { | |
isValid: boolean = true; | |
message: string; | |
name: string; | |
priority: number; | |
result: RuleResult; | |
isDisplayable: boolean; | |
renderType: RenderType = RenderType.EvaluateAllRules; | |
severity: Severity = Severity.Exception; | |
source: string; | |
constructor(name: string, message: string, isDisplayable: boolean); | |
constructor(name: string, message: string, isDisplayable: boolean = false, severity: Severity = Severity.Exception, priority: number = 0) { | |
this.name = name; | |
this.message = message; | |
this.isDisplayable = isDisplayable; | |
this.priority = priority; | |
this.severity = severity; | |
} | |
execute(): RuleResult { | |
console.log('Begin execution of RulePolicy: ' + this.name); | |
return this.render(); | |
} | |
/** | |
* Each rule must implement this function and return a valid [RuleResult]. | |
*/ | |
render(): RuleResult { | |
throw new Error('Each concrete rule must implement this function and return a valid Result.'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment