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
import dCompareResult = require('typescript-dotnet-commonjs/System/CompareResult'); | |
import CompareResult = dCompareResult.CompareResult; | |
import dCompare = require('typescript-dotnet-commonjs/System/Compare'); | |
import Compare = dCompare; | |
import {CompositeRule} from './index'; | |
import {RuleResult} from './RuleResult'; | |
import {Primitive} from './index'; | |
import {IsNotNullOrUndefined} from './index'; | |
import {Min} from './index'; |
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
import dCompareResult = require('typescript-dotnet-commonjs/System/CompareResult'); | |
import CompareResult = dCompareResult.CompareResult; | |
import dCompare = require('typescript-dotnet-commonjs/System/Compare'); | |
import Compare = dCompare; | |
import {CompositeRule} from './index'; | |
import {RuleResult} from './RuleResult'; | |
import {Primitive} from './index'; | |
import {IsNotNullOrUndefined} from './index'; | |
import {Range} from './index'; |
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
import {RulePolicy} from './RulePolicy'; | |
import {RuleResult} from './RuleResult'; | |
export class CompositeRule extends RulePolicy { | |
hasErrors: boolean = false; | |
results: Array<RuleResult> = new Array<RuleResult>(); | |
rules: Array<RulePolicy> = new Array<RulePolicy>(); | |
constructor(name: string, message: string, isDisplayable: boolean) { | |
super(name, message, isDisplayable); |
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 IsTrue extends SimpleRule { | |
target: boolean; | |
constructor(name: string, message: string, target: boolean, isDisplayable: boolean = true) { | |
super(name, message, isDisplayable); | |
this.target = target; | |
} | |
render() { | |
this.isValid = true; |
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
import {RulePolicy} from './RulePolicy'; | |
/** | |
* Use this class as a base [extends] class for simple rules. A simple contains | |
* a single rule and target to evaluate. | |
* | |
* If you require a rule that will contain more than one rule, you should | |
* use extend the [CompositeRule] class. | |
*/ | |
export class SimpleRule extends RulePolicy { |
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
import {RulePolicy} from './index'; | |
import {CompositeRule} from './index'; | |
export class RuleResult { | |
isValid: boolean = false; | |
rulePolicy: RulePolicy; | |
message: string; | |
target: any; | |
constructor(rulePolicy: RulePolicy, target: any); |
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; |
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
// Load the error/rule violations into the ServiceContext so that the information bubbles up to the caller of the service; | |
this.validationContext.results.forEach( (e) => { | |
if(!e.isValid && e.rulePolicy.isDisplayable) { | |
let serviceMessage = new ServiceMessage(e.rulePolicy.name, e.rulePolicy.message, MessageType.Error); | |
this.serviceContext.addMessage(serviceMessage); | |
} | |
} ); |
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
import { CompositeRule } from './CompositeRule'; | |
import { IsNotNullOrUndefined } from './IsNotNullOrUndefined'; | |
import { IsTrue } from './IsTrue'; | |
/** | |
* Use this rule to determine if the string value matches the specified | |
* regular expression. | |
*/ | |
export class StringIsRegExMatch extends CompositeRule { | |
/** |
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
import { CompositeRule, StringIsNotNullEmptyRange, StringIsRegExMatch } from '@buildmotion/rules-engine'; | |
import { RuleConstants } from './rule-constants'; | |
/** | |
* Use to validate the format of an email address. Expects: | |
* | |
* 1. string is not null or undefined | |
* 2. string length is within specified value | |
* 3. string value matches RegEx | |
* |
NewerOlder