Skip to content

Instantly share code, notes, and snippets.

@buildmotion
Created August 28, 2021 19:58
Show Gist options
  • Save buildmotion/0fc08f20759f8a778b5e99b4edbf9206 to your computer and use it in GitHub Desktop.
Save buildmotion/0fc08f20759f8a778b5e99b4edbf9206 to your computer and use it in GitHub Desktop.
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