{"version":3,"sources":["webpack:///./node_modules/aurelia-validation/dist/native-modules/aurelia-validation.js"],"names":["getTargetDOMElement","binding","view","target","Element","i","ii","controllers","length","controller","viewModel","element","container","get","Error","sourceExpression","getObject","expression","objectExpression","source","value","evaluate","Object","getPropertyInfo","object","propertyName","originalExpression","name","ancestor","key","isString","prototype","toString","call","PropertyAccessorParser","parser","this","parse","property","accessorText","getAccessorExpression","accessor","inject","fn","match","exec","validateTrigger","extendStatics","d","b","setPrototypeOf","__proto__","Array","p","hasOwnProperty","__extends","__","constructor","create","__decorate","decorators","desc","c","arguments","r","getOwnPropertyDescriptor","Reflect","decorate","defineProperty","Validator","ValidateResult","rule","valid","message","id","nextId","ValidateEvent","type","errors","results","instruction","controllerValidateResult","ValidationController","validator","propertyParser","bindings","Map","renderers","validating","elements","objects","blur","finishValidating","Promise","resolve","eventCallbacks","subscribe","callback","_this","push","dispose","index","indexOf","splice","addObject","rules","set","removeObject","delete","processResultDelta","filter","result","addError","resolvedPropertyName","__manuallyAdded__","removeError","addRenderer","renderer","render","kind","map","unrender","removeRenderer","registerBinding","propertyInfo","unregisterBinding","resetBinding","getInstructionPredicate","predicate_1","object_1","propertyName_1","rules_1","x","ruleExists","validate","execute","object_2","propertyName_2","rules_2","undefined","validateObject","validateProperty","promises","_i","_a","from","_b","_c","_d","_e","has","all","then","resultSets","reduce","a","concat","returnPromise","newResults","predicate","oldResults","find","invokeCallbacks","catch","exception","reject","reset","getAssociatedElements","slice","_loop_1","oldResult","this_1","newResultIndex","findIndex","newResult","elements_1","oldResults_1","newResults_1","validateBinding","isBound","registeredBinding","changeTrigger","newTrigger","bindings_1","keys","unbind","bind","revalidateErrors","event","ValidateBindingBehaviorBase","taskQueue","rulesOrController","of","validationController","trigger","getValidateTrigger","change","vbbUpdateSource","updateSource","validateBlurHandler","queueMicroTask","validateTarget","addEventListener","manual","standardUpdateTarget","updateTarget","removeEventListener","ValidateBindingBehavior","_super","apply","ValidateManuallyBindingBehavior","ValidateOnBlurBindingBehavior","ValidateOnChangeBindingBehavior","ValidateOnChangeOrBlurBindingBehavior","changeOrBlur","ValidationControllerFactory","createForCurrentScope","registerInstance","ValidationErrorsCustomAttribute","boundaryElement","controllerAccessor","errorsInternal","sort","targets","compareDocumentPosition","interestingElements","e","contains","error","defaultBindingMode","oneWay","primaryProperty","twoWay","ValidationRendererCustomAttribute","created","Rules","Function","enumerable","configurable","writable","unset","ExpressionVisitor","visitChain","chain","visitArgs","expressions","visitBindingBehavior","behavior","accept","args","visitValueConverter","converter","visitAssign","assign","visitConditional","conditional","condition","yes","no","visitAccessThis","access","visitAccessScope","visitAccessMember","visitAccessKeyed","visitCallScope","visitCallFunction","func","visitCallMember","visitPrefix","prefix","visitBinary","binary","left","right","visitLiteralPrimitive","literal","visitLiteralArray","visitLiteralObject","values","visitLiteralString","ValidationMessageParser","bindinqLanguage","emptyStringExpression","nullExpression","undefinedExpression","cache","parts","parseInterpolation","coalesce","MessageExpressionValidator","part","originalMessage","visitor","warn","validationMessages","default","required","matches","email","minLength","maxLength","minItems","maxItems","min","max","range","between","equals","ValidationMessageProvider","getMessage","getDisplayName","displayName","words","split","join","charAt","toUpperCase","StandardValidator","messageProvider","resources","lookupFunctions","messageKey","overrideContext","$displayName","$propertyName","$value","$object","$config","config","$getDisplayName","bindingContext","validateRuleSequence","ruleSequence","sequence","validateAllProperties","allValid","when","promiseOrBoolean","FluentRuleCustomizer","fluentEnsure","fluentRules","parsers","_addRule","withMessageKey","withMessage","tag","ensure","subject","ensureObject","on","satisfies","satisfiesRule","regex","count","expectedValue","FluentRules","customRules","argsToConfig","obj","test","constraint","FluentEnsure","assertInitialized","mergeRules","existingRules","ValidationRules","initialize","messageParser","customRule","taggedRules","untaggedRules","off","AureliaValidationConfiguration","validatorType","customValidator","configure","frameworkConfig","globalResources"],"mappings":"4GAAA,ohDAaA,SAASA,EAAoBC,EAASC,GAClC,IAAIC,EAASF,EAAQE,OAErB,GAAIA,aAAkBC,QAClB,OAAOD,EAIX,I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EnCiS,EAjBwC,GAsBnD,SAASG,EAETC,EAAiBvR,GAGb,IAAI8Q,EAAgBS,EAAgB5W,UAAUC,IAAI2Q,GAC9CpM,EAAiBoS,EAAgB5W,UAAUC,IAAIqB,GACnD2U,EAAgBC,WAAWC,EAAe3R,GAE1C,IAAIoP,EAAS,IAAI4C,EACbnR,aAAoB2I,UACpB3I,EAASuO,GAEbA,EAAOvH,MAAMuK,EAAgB5W,WAEzB4W,EAAgBC,iBAChBD,EAAgBC,gBAAgB1K,EAAyBG,EAAiCC,EAA+BC,EAAiCC,EAAuCK,EAAiCe","file":"npm.aurelia-validation.912223091621d906293b.js","sourcesContent":["import { DOM } from 'aurelia-pal';\nimport { AccessMember, AccessScope, AccessKeyed, BindingBehavior, ValueConverter, getContextFor, Parser, bindingBehavior, bindingMode, LiteralString, Binary, Conditional, LiteralPrimitive, CallMember } from 'aurelia-binding';\nimport { Optional, Lazy } from 'aurelia-dependency-injection';\nimport { TaskQueue } from 'aurelia-task-queue';\nimport { customAttribute, bindable, BindingLanguage, ViewResources } from 'aurelia-templating';\nimport { getLogger } from 'aurelia-logging';\n\n/**\r\n * Gets the DOM element associated with the data-binding. Most of the time it's\r\n * the binding.target but sometimes binding.target is an aurelia custom element,\r\n * or custom attribute which is a javascript \"class\" instance, so we need to use\r\n * the controller's container to retrieve the actual DOM element.\r\n */\r\nfunction getTargetDOMElement(binding, view) {\r\n var target = binding.target;\r\n // DOM element\r\n if (target instanceof Element) {\r\n return target;\r\n }\r\n // custom element or custom attribute\r\n // tslint:disable-next-line:prefer-const\r\n for (var i = 0, ii = view.controllers.length; i < ii; i++) {\r\n var controller = view.controllers[i];\r\n if (controller.viewModel === target) {\r\n var element = controller.container.get(DOM.Element);\r\n if (element) {\r\n return element;\r\n }\r\n throw new Error(\"Unable to locate target element for \\\"\" + binding.sourceExpression + \"\\\".\");\r\n }\r\n }\r\n throw new Error(\"Unable to locate target element for \\\"\" + binding.sourceExpression + \"\\\".\");\r\n}\n\nfunction getObject(expression, objectExpression, source) {\r\n var value = objectExpression.evaluate(source, null);\r\n if (value === null || value === undefined || value instanceof Object) {\r\n return value;\r\n }\r\n // tslint:disable-next-line:max-line-length\r\n throw new Error(\"The '\" + objectExpression + \"' part of '\" + expression + \"' evaluates to \" + value + \" instead of an object, null or undefined.\");\r\n}\r\n/**\r\n * Retrieves the object and property name for the specified expression.\r\n * @param expression The expression\r\n * @param source The scope\r\n */\r\nfunction getPropertyInfo(expression, source) {\r\n var originalExpression = expression;\r\n while (expression instanceof BindingBehavior || expression instanceof ValueConverter) {\r\n expression = expression.expression;\r\n }\r\n var object;\r\n var propertyName;\r\n if (expression instanceof AccessScope) {\r\n object = getContextFor(expression.name, source, expression.ancestor);\r\n propertyName = expression.name;\r\n }\r\n else if (expression instanceof AccessMember) {\r\n object = getObject(originalExpression, expression.object, source);\r\n propertyName = expression.name;\r\n }\r\n else if (expression instanceof AccessKeyed) {\r\n object = getObject(originalExpression, expression.object, source);\r\n propertyName = expression.key.evaluate(source);\r\n }\r\n else {\r\n throw new Error(\"Expression '\" + originalExpression + \"' is not compatible with the validate binding-behavior.\");\r\n }\r\n if (object === null || object === undefined) {\r\n return null;\r\n }\r\n return { object: object, propertyName: propertyName };\r\n}\n\nfunction isString(value) {\r\n return Object.prototype.toString.call(value) === '[object String]';\r\n}\r\nfunction isNumber(value) {\r\n return Object.prototype.toString.call(value) === '[object Number]';\r\n}\n\nvar PropertyAccessorParser = /** @class */ (function () {\r\n function PropertyAccessorParser(parser) {\r\n this.parser = parser;\r\n }\r\n PropertyAccessorParser.prototype.parse = function (property) {\r\n if (isString(property) || isNumber(property)) {\r\n return property;\r\n }\r\n var accessorText = getAccessorExpression(property.toString());\r\n var accessor = this.parser.parse(accessorText);\r\n if (accessor instanceof AccessScope\r\n || accessor instanceof AccessMember && accessor.object instanceof AccessScope) {\r\n return accessor.name;\r\n }\r\n throw new Error(\"Invalid property expression: \\\"\" + accessor + \"\\\"\");\r\n };\r\n PropertyAccessorParser.inject = [Parser];\r\n return PropertyAccessorParser;\r\n}());\r\nfunction getAccessorExpression(fn) {\r\n /* tslint:disable:max-line-length */\r\n var classic = /^function\\s*\\([$_\\w\\d]+\\)\\s*\\{(?:\\s*\"use strict\";)?\\s*(?:[$_\\w\\d.['\"\\]+;]+)?\\s*return\\s+[$_\\w\\d]+\\.([$_\\w\\d]+)\\s*;?\\s*\\}$/;\r\n /* tslint:enable:max-line-length */\r\n var arrow = /^\\(?[$_\\w\\d]+\\)?\\s*=>\\s*[$_\\w\\d]+\\.([$_\\w\\d]+)$/;\r\n var match = classic.exec(fn) || arrow.exec(fn);\r\n if (match === null) {\r\n throw new Error(\"Unable to parse accessor function:\\n\" + fn);\r\n }\r\n return match[1];\r\n}\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nfunction __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\n\n/**\r\n * Validation triggers.\r\n */\r\nvar validateTrigger;\r\n(function (validateTrigger) {\r\n /**\r\n * Manual validation. Use the controller's `validate()` and `reset()` methods\r\n * to validate all bindings.\r\n */\r\n validateTrigger[validateTrigger[\"manual\"] = 0] = \"manual\";\r\n /**\r\n * Validate the binding when the binding's target element fires a DOM \"blur\" event.\r\n */\r\n validateTrigger[validateTrigger[\"blur\"] = 1] = \"blur\";\r\n /**\r\n * Validate the binding when it updates the model due to a change in the view.\r\n */\r\n validateTrigger[validateTrigger[\"change\"] = 2] = \"change\";\r\n /**\r\n * Validate the binding when the binding's target element fires a DOM \"blur\" event and\r\n * when it updates the model due to a change in the view.\r\n */\r\n validateTrigger[validateTrigger[\"changeOrBlur\"] = 3] = \"changeOrBlur\";\r\n})(validateTrigger || (validateTrigger = {}));\n\n/**\r\n * Validates objects and properties.\r\n */\r\nvar Validator = /** @class */ (function () {\r\n function Validator() {\r\n }\r\n return Validator;\r\n}());\n\n/**\r\n * The result of validating an individual validation rule.\r\n */\r\nvar ValidateResult = /** @class */ (function () {\r\n /**\r\n * @param rule The rule associated with the result. Validator implementation specific.\r\n * @param object The object that was validated.\r\n * @param propertyName The name of the property that was validated.\r\n * @param error The error, if the result is a validation error.\r\n */\r\n function ValidateResult(rule, object, propertyName, valid, message) {\r\n if (message === void 0) { message = null; }\r\n this.rule = rule;\r\n this.object = object;\r\n this.propertyName = propertyName;\r\n this.valid = valid;\r\n this.message = message;\r\n this.id = ValidateResult.nextId++;\r\n }\r\n ValidateResult.prototype.toString = function () {\r\n return this.valid ? 'Valid.' : this.message;\r\n };\r\n ValidateResult.nextId = 0;\r\n return ValidateResult;\r\n}());\n\nvar ValidateEvent = /** @class */ (function () {\r\n function ValidateEvent(\r\n /**\r\n * The type of validate event. Either \"validate\" or \"reset\".\r\n */\r\n type, \r\n /**\r\n * The controller's current array of errors. For an array containing both\r\n * failed rules and passed rules, use the \"results\" property.\r\n */\r\n errors, \r\n /**\r\n * The controller's current array of validate results. This\r\n * includes both passed rules and failed rules. For an array of only failed rules,\r\n * use the \"errors\" property.\r\n */\r\n results, \r\n /**\r\n * The instruction passed to the \"validate\" or \"reset\" event. Will be null when\r\n * the controller's validate/reset method was called with no instruction argument.\r\n */\r\n instruction, \r\n /**\r\n * In events with type === \"validate\", this property will contain the result\r\n * of validating the instruction (see \"instruction\" property). Use the controllerValidateResult\r\n * to access the validate results specific to the call to \"validate\"\r\n * (as opposed to using the \"results\" and \"errors\" properties to access the controller's entire\r\n * set of results/errors).\r\n */\r\n controllerValidateResult) {\r\n this.type = type;\r\n this.errors = errors;\r\n this.results = results;\r\n this.instruction = instruction;\r\n this.controllerValidateResult = controllerValidateResult;\r\n }\r\n return ValidateEvent;\r\n}());\n\n/**\r\n * Orchestrates validation.\r\n * Manages a set of bindings, renderers and objects.\r\n * Exposes the current list of validation results for binding purposes.\r\n */\r\nvar ValidationController = /** @class */ (function () {\r\n function ValidationController(validator, propertyParser) {\r\n this.validator = validator;\r\n this.propertyParser = propertyParser;\r\n // Registered bindings (via the validate binding behavior)\r\n this.bindings = new Map();\r\n // Renderers that have been added to the controller instance.\r\n this.renderers = [];\r\n /**\r\n * Validation results that have been rendered by the controller.\r\n */\r\n this.results = [];\r\n /**\r\n * Validation errors that have been rendered by the controller.\r\n */\r\n this.errors = [];\r\n /**\r\n * Whether the controller is currently validating.\r\n */\r\n this.validating = false;\r\n // Elements related to validation results that have been rendered.\r\n this.elements = new Map();\r\n // Objects that have been added to the controller instance (entity-style validation).\r\n this.objects = new Map();\r\n /**\r\n * The trigger that will invoke automatic validation of a property used in a binding.\r\n */\r\n this.validateTrigger = validateTrigger.blur;\r\n // Promise that resolves when validation has completed.\r\n this.finishValidating = Promise.resolve();\r\n this.eventCallbacks = [];\r\n }\r\n /**\r\n * Subscribe to controller validate and reset events. These events occur when the\r\n * controller's \"validate\"\" and \"reset\" methods are called.\r\n * @param callback The callback to be invoked when the controller validates or resets.\r\n */\r\n ValidationController.prototype.subscribe = function (callback) {\r\n var _this = this;\r\n this.eventCallbacks.push(callback);\r\n return {\r\n dispose: function () {\r\n var index = _this.eventCallbacks.indexOf(callback);\r\n if (index === -1) {\r\n return;\r\n }\r\n _this.eventCallbacks.splice(index, 1);\r\n }\r\n };\r\n };\r\n /**\r\n * Adds an object to the set of objects that should be validated when validate is called.\r\n * @param object The object.\r\n * @param rules Optional. The rules. If rules aren't supplied the Validator implementation will lookup the rules.\r\n */\r\n ValidationController.prototype.addObject = function (object, rules) {\r\n this.objects.set(object, rules);\r\n };\r\n /**\r\n * Removes an object from the set of objects that should be validated when validate is called.\r\n * @param object The object.\r\n */\r\n ValidationController.prototype.removeObject = function (object) {\r\n this.objects.delete(object);\r\n this.processResultDelta('reset', this.results.filter(function (result) { return result.object === object; }), []);\r\n };\r\n /**\r\n * Adds and renders an error.\r\n */\r\n ValidationController.prototype.addError = function (message, object, propertyName) {\r\n if (propertyName === void 0) { propertyName = null; }\r\n var resolvedPropertyName;\r\n if (propertyName === null) {\r\n resolvedPropertyName = propertyName;\r\n }\r\n else {\r\n resolvedPropertyName = this.propertyParser.parse(propertyName);\r\n }\r\n var result = new ValidateResult({ __manuallyAdded__: true }, object, resolvedPropertyName, false, message);\r\n this.processResultDelta('validate', [], [result]);\r\n return result;\r\n };\r\n /**\r\n * Removes and unrenders an error.\r\n */\r\n ValidationController.prototype.removeError = function (result) {\r\n if (this.results.indexOf(result) !== -1) {\r\n this.processResultDelta('reset', [result], []);\r\n }\r\n };\r\n /**\r\n * Adds a renderer.\r\n * @param renderer The renderer.\r\n */\r\n ValidationController.prototype.addRenderer = function (renderer) {\r\n var _this = this;\r\n this.renderers.push(renderer);\r\n renderer.render({\r\n kind: 'validate',\r\n render: this.results.map(function (result) { return ({ result: result, elements: _this.elements.get(result) }); }),\r\n unrender: []\r\n });\r\n };\r\n /**\r\n * Removes a renderer.\r\n * @param renderer The renderer.\r\n */\r\n ValidationController.prototype.removeRenderer = function (renderer) {\r\n var _this = this;\r\n this.renderers.splice(this.renderers.indexOf(renderer), 1);\r\n renderer.render({\r\n kind: 'reset',\r\n render: [],\r\n unrender: this.results.map(function (result) { return ({ result: result, elements: _this.elements.get(result) }); })\r\n });\r\n };\r\n /**\r\n * Registers a binding with the controller.\r\n * @param binding The binding instance.\r\n * @param target The DOM element.\r\n * @param rules (optional) rules associated with the binding. Validator implementation specific.\r\n */\r\n ValidationController.prototype.registerBinding = function (binding, target, rules) {\r\n this.bindings.set(binding, { target: target, rules: rules, propertyInfo: null });\r\n };\r\n /**\r\n * Unregisters a binding with the controller.\r\n * @param binding The binding instance.\r\n */\r\n ValidationController.prototype.unregisterBinding = function (binding) {\r\n this.resetBinding(binding);\r\n this.bindings.delete(binding);\r\n };\r\n /**\r\n * Interprets the instruction and returns a predicate that will identify\r\n * relevant results in the list of rendered validation results.\r\n */\r\n ValidationController.prototype.getInstructionPredicate = function (instruction) {\r\n var _this = this;\r\n if (instruction) {\r\n var object_1 = instruction.object, propertyName_1 = instruction.propertyName, rules_1 = instruction.rules;\r\n var predicate_1;\r\n if (instruction.propertyName) {\r\n predicate_1 = function (x) { return x.object === object_1 && x.propertyName === propertyName_1; };\r\n }\r\n else {\r\n predicate_1 = function (x) { return x.object === object_1; };\r\n }\r\n if (rules_1) {\r\n return function (x) { return predicate_1(x) && _this.validator.ruleExists(rules_1, x.rule); };\r\n }\r\n return predicate_1;\r\n }\r\n else {\r\n return function () { return true; };\r\n }\r\n };\r\n /**\r\n * Validates and renders results.\r\n * @param instruction Optional. Instructions on what to validate. If undefined, all\r\n * objects and bindings will be validated.\r\n */\r\n ValidationController.prototype.validate = function (instruction) {\r\n var _this = this;\r\n // Get a function that will process the validation instruction.\r\n var execute;\r\n if (instruction) {\r\n // tslint:disable-next-line:prefer-const\r\n var object_2 = instruction.object, propertyName_2 = instruction.propertyName, rules_2 = instruction.rules;\r\n // if rules were not specified, check the object map.\r\n rules_2 = rules_2 || this.objects.get(object_2);\r\n // property specified?\r\n if (instruction.propertyName === undefined) {\r\n // validate the specified object.\r\n execute = function () { return _this.validator.validateObject(object_2, rules_2); };\r\n }\r\n else {\r\n // validate the specified property.\r\n execute = function () { return _this.validator.validateProperty(object_2, propertyName_2, rules_2); };\r\n }\r\n }\r\n else {\r\n // validate all objects and bindings.\r\n execute = function () {\r\n var promises = [];\r\n for (var _i = 0, _a = Array.from(_this.objects); _i < _a.length; _i++) {\r\n var _b = _a[_i], object = _b[0], rules = _b[1];\r\n promises.push(_this.validator.validateObject(object, rules));\r\n }\r\n for (var _c = 0, _d = Array.from(_this.bindings); _c < _d.length; _c++) {\r\n var _e = _d[_c], binding = _e[0], rules = _e[1].rules;\r\n var propertyInfo = getPropertyInfo(binding.sourceExpression, binding.source);\r\n if (!propertyInfo || _this.objects.has(propertyInfo.object)) {\r\n continue;\r\n }\r\n promises.push(_this.validator.validateProperty(propertyInfo.object, propertyInfo.propertyName, rules));\r\n }\r\n return Promise.all(promises).then(function (resultSets) { return resultSets.reduce(function (a, b) { return a.concat(b); }, []); });\r\n };\r\n }\r\n // Wait for any existing validation to finish, execute the instruction, render the results.\r\n this.validating = true;\r\n var returnPromise = this.finishValidating\r\n .then(execute)\r\n .then(function (newResults) {\r\n var predicate = _this.getInstructionPredicate(instruction);\r\n var oldResults = _this.results.filter(predicate);\r\n _this.processResultDelta('validate', oldResults, newResults);\r\n if (returnPromise === _this.finishValidating) {\r\n _this.validating = false;\r\n }\r\n var result = {\r\n instruction: instruction,\r\n valid: newResults.find(function (x) { return !x.valid; }) === undefined,\r\n results: newResults\r\n };\r\n _this.invokeCallbacks(instruction, result);\r\n return result;\r\n })\r\n .catch(function (exception) {\r\n // recover, to enable subsequent calls to validate()\r\n _this.validating = false;\r\n _this.finishValidating = Promise.resolve();\r\n return Promise.reject(exception);\r\n });\r\n this.finishValidating = returnPromise;\r\n return returnPromise;\r\n };\r\n /**\r\n * Resets any rendered validation results (unrenders).\r\n * @param instruction Optional. Instructions on what to reset. If unspecified all rendered results\r\n * will be unrendered.\r\n */\r\n ValidationController.prototype.reset = function (instruction) {\r\n var predicate = this.getInstructionPredicate(instruction);\r\n var oldResults = this.results.filter(predicate);\r\n this.processResultDelta('reset', oldResults, []);\r\n this.invokeCallbacks(instruction, null);\r\n };\r\n /**\r\n * Gets the elements associated with an object and propertyName (if any).\r\n */\r\n ValidationController.prototype.getAssociatedElements = function (_a) {\r\n var object = _a.object, propertyName = _a.propertyName;\r\n var elements = [];\r\n for (var _i = 0, _b = Array.from(this.bindings); _i < _b.length; _i++) {\r\n var _c = _b[_i], binding = _c[0], target = _c[1].target;\r\n var propertyInfo = getPropertyInfo(binding.sourceExpression, binding.source);\r\n if (propertyInfo && propertyInfo.object === object && propertyInfo.propertyName === propertyName) {\r\n elements.push(target);\r\n }\r\n }\r\n return elements;\r\n };\r\n ValidationController.prototype.processResultDelta = function (kind, oldResults, newResults) {\r\n // prepare the instruction.\r\n var instruction = {\r\n kind: kind,\r\n render: [],\r\n unrender: []\r\n };\r\n // create a shallow copy of newResults so we can mutate it without causing side-effects.\r\n newResults = newResults.slice(0);\r\n var _loop_1 = function (oldResult) {\r\n // get the elements associated with the old result.\r\n var elements = this_1.elements.get(oldResult);\r\n // remove the old result from the element map.\r\n this_1.elements.delete(oldResult);\r\n // create the unrender instruction.\r\n instruction.unrender.push({ result: oldResult, elements: elements });\r\n // determine if there's a corresponding new result for the old result we are unrendering.\r\n var newResultIndex = newResults.findIndex(function (x) { return x.rule === oldResult.rule && x.object === oldResult.object && x.propertyName === oldResult.propertyName; });\r\n if (newResultIndex === -1) {\r\n // no corresponding new result... simple remove.\r\n this_1.results.splice(this_1.results.indexOf(oldResult), 1);\r\n if (!oldResult.valid) {\r\n this_1.errors.splice(this_1.errors.indexOf(oldResult), 1);\r\n }\r\n }\r\n else {\r\n // there is a corresponding new result...\r\n var newResult = newResults.splice(newResultIndex, 1)[0];\r\n // get the elements that are associated with the new result.\r\n var elements_1 = this_1.getAssociatedElements(newResult);\r\n this_1.elements.set(newResult, elements_1);\r\n // create a render instruction for the new result.\r\n instruction.render.push({ result: newResult, elements: elements_1 });\r\n // do an in-place replacement of the old result with the new result.\r\n // this ensures any repeats bound to this.results will not thrash.\r\n this_1.results.splice(this_1.results.indexOf(oldResult), 1, newResult);\r\n if (!oldResult.valid && newResult.valid) {\r\n this_1.errors.splice(this_1.errors.indexOf(oldResult), 1);\r\n }\r\n else if (!oldResult.valid && !newResult.valid) {\r\n this_1.errors.splice(this_1.errors.indexOf(oldResult), 1, newResult);\r\n }\r\n else if (!newResult.valid) {\r\n this_1.errors.push(newResult);\r\n }\r\n }\r\n };\r\n var this_1 = this;\r\n // create unrender instructions from the old results.\r\n for (var _i = 0, oldResults_1 = oldResults; _i < oldResults_1.length; _i++) {\r\n var oldResult = oldResults_1[_i];\r\n _loop_1(oldResult);\r\n }\r\n // create render instructions from the remaining new results.\r\n for (var _a = 0, newResults_1 = newResults; _a < newResults_1.length; _a++) {\r\n var result = newResults_1[_a];\r\n var elements = this.getAssociatedElements(result);\r\n instruction.render.push({ result: result, elements: elements });\r\n this.elements.set(result, elements);\r\n this.results.push(result);\r\n if (!result.valid) {\r\n this.errors.push(result);\r\n }\r\n }\r\n // render.\r\n for (var _b = 0, _c = this.renderers; _b < _c.length; _b++) {\r\n var renderer = _c[_b];\r\n renderer.render(instruction);\r\n }\r\n };\r\n /**\r\n * Validates the property associated with a binding.\r\n */\r\n ValidationController.prototype.validateBinding = function (binding) {\r\n if (!binding.isBound) {\r\n return;\r\n }\r\n var propertyInfo = getPropertyInfo(binding.sourceExpression, binding.source);\r\n var rules;\r\n var registeredBinding = this.bindings.get(binding);\r\n if (registeredBinding) {\r\n rules = registeredBinding.rules;\r\n registeredBinding.propertyInfo = propertyInfo;\r\n }\r\n if (!propertyInfo) {\r\n return;\r\n }\r\n var object = propertyInfo.object, propertyName = propertyInfo.propertyName;\r\n this.validate({ object: object, propertyName: propertyName, rules: rules });\r\n };\r\n /**\r\n * Resets the results for a property associated with a binding.\r\n */\r\n ValidationController.prototype.resetBinding = function (binding) {\r\n var registeredBinding = this.bindings.get(binding);\r\n var propertyInfo = getPropertyInfo(binding.sourceExpression, binding.source);\r\n if (!propertyInfo && registeredBinding) {\r\n propertyInfo = registeredBinding.propertyInfo;\r\n }\r\n if (registeredBinding) {\r\n registeredBinding.propertyInfo = null;\r\n }\r\n if (!propertyInfo) {\r\n return;\r\n }\r\n var object = propertyInfo.object, propertyName = propertyInfo.propertyName;\r\n this.reset({ object: object, propertyName: propertyName });\r\n };\r\n /**\r\n * Changes the controller's validateTrigger.\r\n * @param newTrigger The new validateTrigger\r\n */\r\n ValidationController.prototype.changeTrigger = function (newTrigger) {\r\n this.validateTrigger = newTrigger;\r\n var bindings = Array.from(this.bindings.keys());\r\n for (var _i = 0, bindings_1 = bindings; _i < bindings_1.length; _i++) {\r\n var binding = bindings_1[_i];\r\n var source = binding.source;\r\n binding.unbind();\r\n binding.bind(source);\r\n }\r\n };\r\n /**\r\n * Revalidates the controller's current set of errors.\r\n */\r\n ValidationController.prototype.revalidateErrors = function () {\r\n for (var _i = 0, _a = this.errors; _i < _a.length; _i++) {\r\n var _b = _a[_i], object = _b.object, propertyName = _b.propertyName, rule = _b.rule;\r\n if (rule.__manuallyAdded__) {\r\n continue;\r\n }\r\n var rules = [[rule]];\r\n this.validate({ object: object, propertyName: propertyName, rules: rules });\r\n }\r\n };\r\n ValidationController.prototype.invokeCallbacks = function (instruction, result) {\r\n if (this.eventCallbacks.length === 0) {\r\n return;\r\n }\r\n var event = new ValidateEvent(result ? 'validate' : 'reset', this.errors, this.results, instruction || null, result);\r\n for (var i = 0; i < this.eventCallbacks.length; i++) {\r\n this.eventCallbacks[i](event);\r\n }\r\n };\r\n ValidationController.inject = [Validator, PropertyAccessorParser];\r\n return ValidationController;\r\n}());\n\n/**\r\n * Binding behavior. Indicates the bound property should be validated.\r\n */\r\nvar ValidateBindingBehaviorBase = /** @class */ (function () {\r\n function ValidateBindingBehaviorBase(taskQueue) {\r\n this.taskQueue = taskQueue;\r\n }\r\n ValidateBindingBehaviorBase.prototype.bind = function (binding, source, rulesOrController, rules) {\r\n var _this = this;\r\n // identify the target element.\r\n var target = getTargetDOMElement(binding, source);\r\n // locate the controller.\r\n var controller;\r\n if (rulesOrController instanceof ValidationController) {\r\n controller = rulesOrController;\r\n }\r\n else {\r\n controller = source.container.get(Optional.of(ValidationController));\r\n rules = rulesOrController;\r\n }\r\n if (controller === null) {\r\n throw new Error(\"A ValidationController has not been registered.\");\r\n }\r\n controller.registerBinding(binding, target, rules);\r\n binding.validationController = controller;\r\n var trigger = this.getValidateTrigger(controller);\r\n // tslint:disable-next-line:no-bitwise\r\n if (trigger & validateTrigger.change) {\r\n binding.vbbUpdateSource = binding.updateSource;\r\n // tslint:disable-next-line:only-arrow-functions\r\n // tslint:disable-next-line:space-before-function-paren\r\n binding.updateSource = function (value) {\r\n this.vbbUpdateSource(value);\r\n this.validationController.validateBinding(this);\r\n };\r\n }\r\n // tslint:disable-next-line:no-bitwise\r\n if (trigger & validateTrigger.blur) {\r\n binding.validateBlurHandler = function () {\r\n _this.taskQueue.queueMicroTask(function () { return controller.validateBinding(binding); });\r\n };\r\n binding.validateTarget = target;\r\n target.addEventListener('blur', binding.validateBlurHandler);\r\n }\r\n if (trigger !== validateTrigger.manual) {\r\n binding.standardUpdateTarget = binding.updateTarget;\r\n // tslint:disable-next-line:only-arrow-functions\r\n // tslint:disable-next-line:space-before-function-paren\r\n binding.updateTarget = function (value) {\r\n this.standardUpdateTarget(value);\r\n this.validationController.resetBinding(this);\r\n };\r\n }\r\n };\r\n ValidateBindingBehaviorBase.prototype.unbind = function (binding) {\r\n // reset the binding to it's original state.\r\n if (binding.vbbUpdateSource) {\r\n binding.updateSource = binding.vbbUpdateSource;\r\n binding.vbbUpdateSource = null;\r\n }\r\n if (binding.standardUpdateTarget) {\r\n binding.updateTarget = binding.standardUpdateTarget;\r\n binding.standardUpdateTarget = null;\r\n }\r\n if (binding.validateBlurHandler) {\r\n binding.validateTarget.removeEventListener('blur', binding.validateBlurHandler);\r\n binding.validateBlurHandler = null;\r\n binding.validateTarget = null;\r\n }\r\n binding.validationController.unregisterBinding(binding);\r\n binding.validationController = null;\r\n };\r\n return ValidateBindingBehaviorBase;\r\n}());\n\n/**\r\n * Binding behavior. Indicates the bound property should be validated\r\n * when the validate trigger specified by the associated controller's\r\n * validateTrigger property occurs.\r\n */\r\nvar ValidateBindingBehavior = /** @class */ (function (_super) {\r\n __extends(ValidateBindingBehavior, _super);\r\n function ValidateBindingBehavior() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n ValidateBindingBehavior.prototype.getValidateTrigger = function (controller) {\r\n return controller.validateTrigger;\r\n };\r\n ValidateBindingBehavior.inject = [TaskQueue];\r\n ValidateBindingBehavior = __decorate([\r\n bindingBehavior('validate')\r\n ], ValidateBindingBehavior);\r\n return ValidateBindingBehavior;\r\n}(ValidateBindingBehaviorBase));\r\n/**\r\n * Binding behavior. Indicates the bound property will be validated\r\n * manually, by calling controller.validate(). No automatic validation\r\n * triggered by data-entry or blur will occur.\r\n */\r\nvar ValidateManuallyBindingBehavior = /** @class */ (function (_super) {\r\n __extends(ValidateManuallyBindingBehavior, _super);\r\n function ValidateManuallyBindingBehavior() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n ValidateManuallyBindingBehavior.prototype.getValidateTrigger = function () {\r\n return validateTrigger.manual;\r\n };\r\n ValidateManuallyBindingBehavior.inject = [TaskQueue];\r\n ValidateManuallyBindingBehavior = __decorate([\r\n bindingBehavior('validateManually')\r\n ], ValidateManuallyBindingBehavior);\r\n return ValidateManuallyBindingBehavior;\r\n}(ValidateBindingBehaviorBase));\r\n/**\r\n * Binding behavior. Indicates the bound property should be validated\r\n * when the associated element blurs.\r\n */\r\nvar ValidateOnBlurBindingBehavior = /** @class */ (function (_super) {\r\n __extends(ValidateOnBlurBindingBehavior, _super);\r\n function ValidateOnBlurBindingBehavior() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n ValidateOnBlurBindingBehavior.prototype.getValidateTrigger = function () {\r\n return validateTrigger.blur;\r\n };\r\n ValidateOnBlurBindingBehavior.inject = [TaskQueue];\r\n ValidateOnBlurBindingBehavior = __decorate([\r\n bindingBehavior('validateOnBlur')\r\n ], ValidateOnBlurBindingBehavior);\r\n return ValidateOnBlurBindingBehavior;\r\n}(ValidateBindingBehaviorBase));\r\n/**\r\n * Binding behavior. Indicates the bound property should be validated\r\n * when the associated element is changed by the user, causing a change\r\n * to the model.\r\n */\r\nvar ValidateOnChangeBindingBehavior = /** @class */ (function (_super) {\r\n __extends(ValidateOnChangeBindingBehavior, _super);\r\n function ValidateOnChangeBindingBehavior() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n ValidateOnChangeBindingBehavior.prototype.getValidateTrigger = function () {\r\n return validateTrigger.change;\r\n };\r\n ValidateOnChangeBindingBehavior.inject = [TaskQueue];\r\n ValidateOnChangeBindingBehavior = __decorate([\r\n bindingBehavior('validateOnChange')\r\n ], ValidateOnChangeBindingBehavior);\r\n return ValidateOnChangeBindingBehavior;\r\n}(ValidateBindingBehaviorBase));\r\n/**\r\n * Binding behavior. Indicates the bound property should be validated\r\n * when the associated element blurs or is changed by the user, causing\r\n * a change to the model.\r\n */\r\nvar ValidateOnChangeOrBlurBindingBehavior = /** @class */ (function (_super) {\r\n __extends(ValidateOnChangeOrBlurBindingBehavior, _super);\r\n function ValidateOnChangeOrBlurBindingBehavior() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n ValidateOnChangeOrBlurBindingBehavior.prototype.getValidateTrigger = function () {\r\n return validateTrigger.changeOrBlur;\r\n };\r\n ValidateOnChangeOrBlurBindingBehavior.inject = [TaskQueue];\r\n ValidateOnChangeOrBlurBindingBehavior = __decorate([\r\n bindingBehavior('validateOnChangeOrBlur')\r\n ], ValidateOnChangeOrBlurBindingBehavior);\r\n return ValidateOnChangeOrBlurBindingBehavior;\r\n}(ValidateBindingBehaviorBase));\n\n/**\r\n * Creates ValidationController instances.\r\n */\r\nvar ValidationControllerFactory = /** @class */ (function () {\r\n function ValidationControllerFactory(container) {\r\n this.container = container;\r\n }\r\n ValidationControllerFactory.get = function (container) {\r\n return new ValidationControllerFactory(container);\r\n };\r\n /**\r\n * Creates a new controller instance.\r\n */\r\n ValidationControllerFactory.prototype.create = function (validator) {\r\n if (!validator) {\r\n validator = this.container.get(Validator);\r\n }\r\n var propertyParser = this.container.get(PropertyAccessorParser);\r\n return new ValidationController(validator, propertyParser);\r\n };\r\n /**\r\n * Creates a new controller and registers it in the current element's container so that it's\r\n * available to the validate binding behavior and renderers.\r\n */\r\n ValidationControllerFactory.prototype.createForCurrentScope = function (validator) {\r\n var controller = this.create(validator);\r\n this.container.registerInstance(ValidationController, controller);\r\n return controller;\r\n };\r\n return ValidationControllerFactory;\r\n}());\r\nValidationControllerFactory['protocol:aurelia:resolver'] = true;\n\nvar ValidationErrorsCustomAttribute = /** @class */ (function () {\r\n function ValidationErrorsCustomAttribute(boundaryElement, controllerAccessor) {\r\n this.boundaryElement = boundaryElement;\r\n this.controllerAccessor = controllerAccessor;\r\n this.controller = null;\r\n this.errors = [];\r\n this.errorsInternal = [];\r\n }\r\n ValidationErrorsCustomAttribute.inject = function () {\r\n return [DOM.Element, Lazy.of(ValidationController)];\r\n };\r\n ValidationErrorsCustomAttribute.prototype.sort = function () {\r\n this.errorsInternal.sort(function (a, b) {\r\n if (a.targets[0] === b.targets[0]) {\r\n return 0;\r\n }\r\n // tslint:disable-next-line:no-bitwise\r\n return a.targets[0].compareDocumentPosition(b.targets[0]) & 2 ? 1 : -1;\r\n });\r\n };\r\n ValidationErrorsCustomAttribute.prototype.interestingElements = function (elements) {\r\n var _this = this;\r\n return elements.filter(function (e) { return _this.boundaryElement.contains(e); });\r\n };\r\n ValidationErrorsCustomAttribute.prototype.render = function (instruction) {\r\n var _loop_1 = function (result) {\r\n var index = this_1.errorsInternal.findIndex(function (x) { return x.error === result; });\r\n if (index !== -1) {\r\n this_1.errorsInternal.splice(index, 1);\r\n }\r\n };\r\n var this_1 = this;\r\n for (var _i = 0, _a = instruction.unrender; _i < _a.length; _i++) {\r\n var result = _a[_i].result;\r\n _loop_1(result);\r\n }\r\n for (var _b = 0, _c = instruction.render; _b < _c.length; _b++) {\r\n var _d = _c[_b], result = _d.result, elements = _d.elements;\r\n if (result.valid) {\r\n continue;\r\n }\r\n var targets = this.interestingElements(elements);\r\n if (targets.length) {\r\n this.errorsInternal.push({ error: result, targets: targets });\r\n }\r\n }\r\n this.sort();\r\n this.errors = this.errorsInternal;\r\n };\r\n ValidationErrorsCustomAttribute.prototype.bind = function () {\r\n if (!this.controller) {\r\n this.controller = this.controllerAccessor();\r\n }\r\n // this will call render() with the side-effect of updating this.errors\r\n this.controller.addRenderer(this);\r\n };\r\n ValidationErrorsCustomAttribute.prototype.unbind = function () {\r\n if (this.controller) {\r\n this.controller.removeRenderer(this);\r\n }\r\n };\r\n __decorate([\r\n bindable({ defaultBindingMode: bindingMode.oneWay })\r\n ], ValidationErrorsCustomAttribute.prototype, \"controller\", void 0);\r\n __decorate([\r\n bindable({ primaryProperty: true, defaultBindingMode: bindingMode.twoWay })\r\n ], ValidationErrorsCustomAttribute.prototype, \"errors\", void 0);\r\n ValidationErrorsCustomAttribute = __decorate([\r\n customAttribute('validation-errors')\r\n ], ValidationErrorsCustomAttribute);\r\n return ValidationErrorsCustomAttribute;\r\n}());\n\nvar ValidationRendererCustomAttribute = /** @class */ (function () {\r\n function ValidationRendererCustomAttribute() {\r\n }\r\n ValidationRendererCustomAttribute.prototype.created = function (view) {\r\n this.container = view.container;\r\n };\r\n ValidationRendererCustomAttribute.prototype.bind = function () {\r\n this.controller = this.container.get(ValidationController);\r\n this.renderer = this.container.get(this.value);\r\n this.controller.addRenderer(this.renderer);\r\n };\r\n ValidationRendererCustomAttribute.prototype.unbind = function () {\r\n this.controller.removeRenderer(this.renderer);\r\n this.controller = null;\r\n this.renderer = null;\r\n };\r\n ValidationRendererCustomAttribute = __decorate([\r\n customAttribute('validation-renderer')\r\n ], ValidationRendererCustomAttribute);\r\n return ValidationRendererCustomAttribute;\r\n}());\n\n/**\r\n * Sets, unsets and retrieves rules on an object or constructor function.\r\n */\r\nvar Rules = /** @class */ (function () {\r\n function Rules() {\r\n }\r\n /**\r\n * Applies the rules to a target.\r\n */\r\n Rules.set = function (target, rules) {\r\n if (target instanceof Function) {\r\n target = target.prototype;\r\n }\r\n Object.defineProperty(target, Rules.key, { enumerable: false, configurable: false, writable: true, value: rules });\r\n };\r\n /**\r\n * Removes rules from a target.\r\n */\r\n Rules.unset = function (target) {\r\n if (target instanceof Function) {\r\n target = target.prototype;\r\n }\r\n target[Rules.key] = null;\r\n };\r\n /**\r\n * Retrieves the target's rules.\r\n */\r\n Rules.get = function (target) {\r\n return target[Rules.key] || null;\r\n };\r\n /**\r\n * The name of the property that stores the rules.\r\n */\r\n Rules.key = '__rules__';\r\n return Rules;\r\n}());\n\n// tslint:disable:no-empty\r\nvar ExpressionVisitor = /** @class */ (function () {\r\n function ExpressionVisitor() {\r\n }\r\n ExpressionVisitor.prototype.visitChain = function (chain) {\r\n this.visitArgs(chain.expressions);\r\n };\r\n ExpressionVisitor.prototype.visitBindingBehavior = function (behavior) {\r\n behavior.expression.accept(this);\r\n this.visitArgs(behavior.args);\r\n };\r\n ExpressionVisitor.prototype.visitValueConverter = function (converter) {\r\n converter.expression.accept(this);\r\n this.visitArgs(converter.args);\r\n };\r\n ExpressionVisitor.prototype.visitAssign = function (assign) {\r\n assign.target.accept(this);\r\n assign.value.accept(this);\r\n };\r\n ExpressionVisitor.prototype.visitConditional = function (conditional) {\r\n conditional.condition.accept(this);\r\n conditional.yes.accept(this);\r\n conditional.no.accept(this);\r\n };\r\n ExpressionVisitor.prototype.visitAccessThis = function (access) {\r\n access.ancestor = access.ancestor;\r\n };\r\n ExpressionVisitor.prototype.visitAccessScope = function (access) {\r\n access.name = access.name;\r\n };\r\n ExpressionVisitor.prototype.visitAccessMember = function (access) {\r\n access.object.accept(this);\r\n };\r\n ExpressionVisitor.prototype.visitAccessKeyed = function (access) {\r\n access.object.accept(this);\r\n access.key.accept(this);\r\n };\r\n ExpressionVisitor.prototype.visitCallScope = function (call) {\r\n this.visitArgs(call.args);\r\n };\r\n ExpressionVisitor.prototype.visitCallFunction = function (call) {\r\n call.func.accept(this);\r\n this.visitArgs(call.args);\r\n };\r\n ExpressionVisitor.prototype.visitCallMember = function (call) {\r\n call.object.accept(this);\r\n this.visitArgs(call.args);\r\n };\r\n ExpressionVisitor.prototype.visitPrefix = function (prefix) {\r\n prefix.expression.accept(this);\r\n };\r\n ExpressionVisitor.prototype.visitBinary = function (binary) {\r\n binary.left.accept(this);\r\n binary.right.accept(this);\r\n };\r\n ExpressionVisitor.prototype.visitLiteralPrimitive = function (literal) {\r\n literal.value = literal.value;\r\n };\r\n ExpressionVisitor.prototype.visitLiteralArray = function (literal) {\r\n this.visitArgs(literal.elements);\r\n };\r\n ExpressionVisitor.prototype.visitLiteralObject = function (literal) {\r\n this.visitArgs(literal.values);\r\n };\r\n ExpressionVisitor.prototype.visitLiteralString = function (literal) {\r\n literal.value = literal.value;\r\n };\r\n ExpressionVisitor.prototype.visitArgs = function (args) {\r\n for (var i = 0; i < args.length; i++) {\r\n args[i].accept(this);\r\n }\r\n };\r\n return ExpressionVisitor;\r\n}());\n\nvar ValidationMessageParser = /** @class */ (function () {\r\n function ValidationMessageParser(bindinqLanguage) {\r\n this.bindinqLanguage = bindinqLanguage;\r\n this.emptyStringExpression = new LiteralString('');\r\n this.nullExpression = new LiteralPrimitive(null);\r\n this.undefinedExpression = new LiteralPrimitive(undefined);\r\n this.cache = {};\r\n }\r\n ValidationMessageParser.prototype.parse = function (message) {\r\n if (this.cache[message] !== undefined) {\r\n return this.cache[message];\r\n }\r\n var parts = this.bindinqLanguage.parseInterpolation(null, message);\r\n if (parts === null) {\r\n return new LiteralString(message);\r\n }\r\n var expression = new LiteralString(parts[0]);\r\n for (var i = 1; i < parts.length; i += 2) {\r\n expression = new Binary('+', expression, new Binary('+', this.coalesce(parts[i]), new LiteralString(parts[i + 1])));\r\n }\r\n MessageExpressionValidator.validate(expression, message);\r\n this.cache[message] = expression;\r\n return expression;\r\n };\r\n ValidationMessageParser.prototype.coalesce = function (part) {\r\n // part === null || part === undefined ? '' : part\r\n return new Conditional(new Binary('||', new Binary('===', part, this.nullExpression), new Binary('===', part, this.undefinedExpression)), this.emptyStringExpression, new CallMember(part, 'toString', []));\r\n };\r\n ValidationMessageParser.inject = [BindingLanguage];\r\n return ValidationMessageParser;\r\n}());\r\nvar MessageExpressionValidator = /** @class */ (function (_super) {\r\n __extends(MessageExpressionValidator, _super);\r\n function MessageExpressionValidator(originalMessage) {\r\n var _this = _super.call(this) || this;\r\n _this.originalMessage = originalMessage;\r\n return _this;\r\n }\r\n MessageExpressionValidator.validate = function (expression, originalMessage) {\r\n var visitor = new MessageExpressionValidator(originalMessage);\r\n expression.accept(visitor);\r\n };\r\n MessageExpressionValidator.prototype.visitAccessScope = function (access) {\r\n if (access.ancestor !== 0) {\r\n throw new Error('$parent is not permitted in validation message expressions.');\r\n }\r\n if (['displayName', 'propertyName', 'value', 'object', 'config', 'getDisplayName'].indexOf(access.name) !== -1) {\r\n getLogger('aurelia-validation')\r\n // tslint:disable-next-line:max-line-length\r\n .warn(\"Did you mean to use \\\"$\" + access.name + \"\\\" instead of \\\"\" + access.name + \"\\\" in this validation message template: \\\"\" + this.originalMessage + \"\\\"?\");\r\n }\r\n };\r\n return MessageExpressionValidator;\r\n}(ExpressionVisitor));\n\n/**\r\n * Dictionary of validation messages. [messageKey]: messageExpression\r\n */\r\nvar validationMessages = {\r\n /**\r\n * The default validation message. Used with rules that have no standard message.\r\n */\r\n default: \"${$displayName} is invalid.\",\r\n required: \"${$displayName} is required.\",\r\n matches: \"${$displayName} is not correctly formatted.\",\r\n email: \"${$displayName} is not a valid email.\",\r\n minLength: \"${$displayName} must be at least ${$config.length} character${$config.length === 1 ? '' : 's'}.\",\r\n maxLength: \"${$displayName} cannot be longer than ${$config.length} character${$config.length === 1 ? '' : 's'}.\",\r\n minItems: \"${$displayName} must contain at least ${$config.count} item${$config.count === 1 ? '' : 's'}.\",\r\n maxItems: \"${$displayName} cannot contain more than ${$config.count} item${$config.count === 1 ? '' : 's'}.\",\r\n min: \"${$displayName} must be at least ${$config.constraint}.\",\r\n max: \"${$displayName} must be at most ${$config.constraint}.\",\r\n range: \"${$displayName} must be between or equal to ${$config.min} and ${$config.max}.\",\r\n between: \"${$displayName} must be between but not equal to ${$config.min} and ${$config.max}.\",\r\n equals: \"${$displayName} must be ${$config.expectedValue}.\",\r\n};\r\n/**\r\n * Retrieves validation messages and property display names.\r\n */\r\nvar ValidationMessageProvider = /** @class */ (function () {\r\n function ValidationMessageProvider(parser) {\r\n this.parser = parser;\r\n }\r\n /**\r\n * Returns a message binding expression that corresponds to the key.\r\n * @param key The message key.\r\n */\r\n ValidationMessageProvider.prototype.getMessage = function (key) {\r\n var message;\r\n if (key in validationMessages) {\r\n message = validationMessages[key];\r\n }\r\n else {\r\n message = validationMessages['default'];\r\n }\r\n return this.parser.parse(message);\r\n };\r\n /**\r\n * Formulates a property display name using the property name and the configured\r\n * displayName (if provided).\r\n * Override this with your own custom logic.\r\n * @param propertyName The property name.\r\n */\r\n ValidationMessageProvider.prototype.getDisplayName = function (propertyName, displayName) {\r\n if (displayName !== null && displayName !== undefined) {\r\n return (displayName instanceof Function) ? displayName() : displayName;\r\n }\r\n // split on upper-case letters.\r\n var words = propertyName.toString().split(/(?=[A-Z])/).join(' ');\r\n // capitalize first letter.\r\n return words.charAt(0).toUpperCase() + words.slice(1);\r\n };\r\n ValidationMessageProvider.inject = [ValidationMessageParser];\r\n return ValidationMessageProvider;\r\n}());\n\n/**\r\n * Validates.\r\n * Responsible for validating objects and properties.\r\n */\r\nvar StandardValidator = /** @class */ (function (_super) {\r\n __extends(StandardValidator, _super);\r\n function StandardValidator(messageProvider, resources) {\r\n var _this = _super.call(this) || this;\r\n _this.messageProvider = messageProvider;\r\n _this.lookupFunctions = resources.lookupFunctions;\r\n _this.getDisplayName = messageProvider.getDisplayName.bind(messageProvider);\r\n return _this;\r\n }\r\n /**\r\n * Validates the specified property.\r\n * @param object The object to validate.\r\n * @param propertyName The name of the property to validate.\r\n * @param rules Optional. If unspecified, the rules will be looked up using the metadata\r\n * for the object created by ValidationRules....on(class/object)\r\n */\r\n StandardValidator.prototype.validateProperty = function (object, propertyName, rules) {\r\n return this.validate(object, propertyName, rules || null);\r\n };\r\n /**\r\n * Validates all rules for specified object and it's properties.\r\n * @param object The object to validate.\r\n * @param rules Optional. If unspecified, the rules will be looked up using the metadata\r\n * for the object created by ValidationRules....on(class/object)\r\n */\r\n StandardValidator.prototype.validateObject = function (object, rules) {\r\n return this.validate(object, null, rules || null);\r\n };\r\n /**\r\n * Determines whether a rule exists in a set of rules.\r\n * @param rules The rules to search.\r\n * @parem rule The rule to find.\r\n */\r\n StandardValidator.prototype.ruleExists = function (rules, rule) {\r\n var i = rules.length;\r\n while (i--) {\r\n if (rules[i].indexOf(rule) !== -1) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n };\r\n StandardValidator.prototype.getMessage = function (rule, object, value) {\r\n var expression = rule.message || this.messageProvider.getMessage(rule.messageKey);\r\n // tslint:disable-next-line:prefer-const\r\n var _a = rule.property, propertyName = _a.name, displayName = _a.displayName;\r\n if (propertyName !== null) {\r\n displayName = this.messageProvider.getDisplayName(propertyName, displayName);\r\n }\r\n var overrideContext = {\r\n $displayName: displayName,\r\n $propertyName: propertyName,\r\n $value: value,\r\n $object: object,\r\n $config: rule.config,\r\n // returns the name of a given property, given just the property name (irrespective of the property's displayName)\r\n // split on capital letters, first letter ensured to be capitalized\r\n $getDisplayName: this.getDisplayName\r\n };\r\n return expression.evaluate({ bindingContext: object, overrideContext: overrideContext }, this.lookupFunctions);\r\n };\r\n StandardValidator.prototype.validateRuleSequence = function (object, propertyName, ruleSequence, sequence, results) {\r\n var _this = this;\r\n // are we validating all properties or a single property?\r\n var validateAllProperties = propertyName === null || propertyName === undefined;\r\n var rules = ruleSequence[sequence];\r\n var allValid = true;\r\n // validate each rule.\r\n var promises = [];\r\n var _loop_1 = function (i) {\r\n var rule = rules[i];\r\n // is the rule related to the property we're validating.\r\n // tslint:disable-next-line:triple-equals | Use loose equality for property keys\r\n if (!validateAllProperties && rule.property.name != propertyName) {\r\n return \"continue\";\r\n }\r\n // is this a conditional rule? is the condition met?\r\n if (rule.when && !rule.when(object)) {\r\n return \"continue\";\r\n }\r\n // validate.\r\n var value = rule.property.name === null ? object : object[rule.property.name];\r\n var promiseOrBoolean = rule.condition(value, object);\r\n if (!(promiseOrBoolean instanceof Promise)) {\r\n promiseOrBoolean = Promise.resolve(promiseOrBoolean);\r\n }\r\n promises.push(promiseOrBoolean.then(function (valid) {\r\n var message = valid ? null : _this.getMessage(rule, object, value);\r\n results.push(new ValidateResult(rule, object, rule.property.name, valid, message));\r\n allValid = allValid && valid;\r\n return valid;\r\n }));\r\n };\r\n for (var i = 0; i < rules.length; i++) {\r\n _loop_1(i);\r\n }\r\n return Promise.all(promises)\r\n .then(function () {\r\n sequence++;\r\n if (allValid && sequence < ruleSequence.length) {\r\n return _this.validateRuleSequence(object, propertyName, ruleSequence, sequence, results);\r\n }\r\n return results;\r\n });\r\n };\r\n StandardValidator.prototype.validate = function (object, propertyName, rules) {\r\n // rules specified?\r\n if (!rules) {\r\n // no. attempt to locate the rules.\r\n rules = Rules.get(object);\r\n }\r\n // any rules?\r\n if (!rules || rules.length === 0) {\r\n return Promise.resolve([]);\r\n }\r\n return this.validateRuleSequence(object, propertyName, rules, 0, []);\r\n };\r\n StandardValidator.inject = [ValidationMessageProvider, ViewResources];\r\n return StandardValidator;\r\n}(Validator));\n\n/**\r\n * Part of the fluent rule API. Enables customizing property rules.\r\n */\r\nvar FluentRuleCustomizer = /** @class */ (function () {\r\n function FluentRuleCustomizer(property, condition, config, fluentEnsure, fluentRules, parsers) {\r\n if (config === void 0) { config = {}; }\r\n this.fluentEnsure = fluentEnsure;\r\n this.fluentRules = fluentRules;\r\n this.parsers = parsers;\r\n this.rule = {\r\n property: property,\r\n condition: condition,\r\n config: config,\r\n when: null,\r\n messageKey: 'default',\r\n message: null,\r\n sequence: fluentRules.sequence\r\n };\r\n this.fluentEnsure._addRule(this.rule);\r\n }\r\n /**\r\n * Validate subsequent rules after previously declared rules have\r\n * been validated successfully. Use to postpone validation of costly\r\n * rules until less expensive rules pass validation.\r\n */\r\n FluentRuleCustomizer.prototype.then = function () {\r\n this.fluentRules.sequence++;\r\n return this;\r\n };\r\n /**\r\n * Specifies the key to use when looking up the rule's validation message.\r\n */\r\n FluentRuleCustomizer.prototype.withMessageKey = function (key) {\r\n this.rule.messageKey = key;\r\n this.rule.message = null;\r\n return this;\r\n };\r\n /**\r\n * Specifies rule's validation message.\r\n */\r\n FluentRuleCustomizer.prototype.withMessage = function (message) {\r\n this.rule.messageKey = 'custom';\r\n this.rule.message = this.parsers.message.parse(message);\r\n return this;\r\n };\r\n /**\r\n * Specifies a condition that must be met before attempting to validate the rule.\r\n * @param condition A function that accepts the object as a parameter and returns true\r\n * or false whether the rule should be evaluated.\r\n */\r\n FluentRuleCustomizer.prototype.when = function (condition) {\r\n this.rule.when = condition;\r\n return this;\r\n };\r\n /**\r\n * Tags the rule instance, enabling the rule to be found easily\r\n * using ValidationRules.taggedRules(rules, tag)\r\n */\r\n FluentRuleCustomizer.prototype.tag = function (tag) {\r\n this.rule.tag = tag;\r\n return this;\r\n };\r\n ///// FluentEnsure APIs /////\r\n /**\r\n * Target a property with validation rules.\r\n * @param property The property to target. Can be the property name or a property accessor function.\r\n */\r\n FluentRuleCustomizer.prototype.ensure = function (subject) {\r\n return this.fluentEnsure.ensure(subject);\r\n };\r\n /**\r\n * Targets an object with validation rules.\r\n */\r\n FluentRuleCustomizer.prototype.ensureObject = function () {\r\n return this.fluentEnsure.ensureObject();\r\n };\r\n Object.defineProperty(FluentRuleCustomizer.prototype, \"rules\", {\r\n /**\r\n * Rules that have been defined using the fluent API.\r\n */\r\n get: function () {\r\n return this.fluentEnsure.rules;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Applies the rules to a class or object, making them discoverable by the StandardValidator.\r\n * @param target A class or object.\r\n */\r\n FluentRuleCustomizer.prototype.on = function (target) {\r\n return this.fluentEnsure.on(target);\r\n };\r\n ///////// FluentRules APIs /////////\r\n /**\r\n * Applies an ad-hoc rule function to the ensured property or object.\r\n * @param condition The function to validate the rule.\r\n * Will be called with two arguments, the property value and the object.\r\n * Should return a boolean or a Promise that resolves to a boolean.\r\n */\r\n FluentRuleCustomizer.prototype.satisfies = function (condition, config) {\r\n return this.fluentRules.satisfies(condition, config);\r\n };\r\n /**\r\n * Applies a rule by name.\r\n * @param name The name of the custom or standard rule.\r\n * @param args The rule's arguments.\r\n */\r\n FluentRuleCustomizer.prototype.satisfiesRule = function (name) {\r\n var args = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n args[_i - 1] = arguments[_i];\r\n }\r\n var _a;\r\n return (_a = this.fluentRules).satisfiesRule.apply(_a, [name].concat(args));\r\n };\r\n /**\r\n * Applies the \"required\" rule to the property.\r\n * The value cannot be null, undefined or whitespace.\r\n */\r\n FluentRuleCustomizer.prototype.required = function () {\r\n return this.fluentRules.required();\r\n };\r\n /**\r\n * Applies the \"matches\" rule to the property.\r\n * Value must match the specified regular expression.\r\n * null, undefined and empty-string values are considered valid.\r\n */\r\n FluentRuleCustomizer.prototype.matches = function (regex) {\r\n return this.fluentRules.matches(regex);\r\n };\r\n /**\r\n * Applies the \"email\" rule to the property.\r\n * null, undefined and empty-string values are considered valid.\r\n */\r\n FluentRuleCustomizer.prototype.email = function () {\r\n return this.fluentRules.email();\r\n };\r\n /**\r\n * Applies the \"minLength\" STRING validation rule to the property.\r\n * null, undefined and empty-string values are considered valid.\r\n */\r\n FluentRuleCustomizer.prototype.minLength = function (length) {\r\n return this.fluentRules.minLength(length);\r\n };\r\n /**\r\n * Applies the \"maxLength\" STRING validation rule to the property.\r\n * null, undefined and empty-string values are considered valid.\r\n */\r\n FluentRuleCustomizer.prototype.maxLength = function (length) {\r\n return this.fluentRules.maxLength(length);\r\n };\r\n /**\r\n * Applies the \"minItems\" ARRAY validation rule to the property.\r\n * null and undefined values are considered valid.\r\n */\r\n FluentRuleCustomizer.prototype.minItems = function (count) {\r\n return this.fluentRules.minItems(count);\r\n };\r\n /**\r\n * Applies the \"maxItems\" ARRAY validation rule to the property.\r\n * null and undefined values are considered valid.\r\n */\r\n FluentRuleCustomizer.prototype.maxItems = function (count) {\r\n return this.fluentRules.maxItems(count);\r\n };\r\n /**\r\n * Applies the \"min\" NUMBER validation rule to the property.\r\n * Value must be greater than or equal to the specified constraint.\r\n * null and undefined values are considered valid.\r\n */\r\n FluentRuleCustomizer.prototype.min = function (value) {\r\n return this.fluentRules.min(value);\r\n };\r\n /**\r\n * Applies the \"max\" NUMBER validation rule to the property.\r\n * Value must be less than or equal to the specified constraint.\r\n * null and undefined values are considered valid.\r\n */\r\n FluentRuleCustomizer.prototype.max = function (value) {\r\n return this.fluentRules.max(value);\r\n };\r\n /**\r\n * Applies the \"range\" NUMBER validation rule to the property.\r\n * Value must be between or equal to the specified min and max.\r\n * null and undefined values are considered valid.\r\n */\r\n FluentRuleCustomizer.prototype.range = function (min, max) {\r\n return this.fluentRules.range(min, max);\r\n };\r\n /**\r\n * Applies the \"between\" NUMBER validation rule to the property.\r\n * Value must be between but not equal to the specified min and max.\r\n * null and undefined values are considered valid.\r\n */\r\n FluentRuleCustomizer.prototype.between = function (min, max) {\r\n return this.fluentRules.between(min, max);\r\n };\r\n /**\r\n * Applies the \"equals\" validation rule to the property.\r\n * null, undefined and empty-string values are considered valid.\r\n */\r\n FluentRuleCustomizer.prototype.equals = function (expectedValue) {\r\n return this.fluentRules.equals(expectedValue);\r\n };\r\n return FluentRuleCustomizer;\r\n}());\r\n/**\r\n * Part of the fluent rule API. Enables applying rules to properties and objects.\r\n */\r\nvar FluentRules = /** @class */ (function () {\r\n function FluentRules(fluentEnsure, parsers, property) {\r\n this.fluentEnsure = fluentEnsure;\r\n this.parsers = parsers;\r\n this.property = property;\r\n /**\r\n * Current rule sequence number. Used to postpone evaluation of rules until rules\r\n * with lower sequence number have successfully validated. The \"then\" fluent API method\r\n * manages this property, there's usually no need to set it directly.\r\n */\r\n this.sequence = 0;\r\n }\r\n /**\r\n * Sets the display name of the ensured property.\r\n */\r\n FluentRules.prototype.displayName = function (name) {\r\n this.property.displayName = name;\r\n return this;\r\n };\r\n /**\r\n * Applies an ad-hoc rule function to the ensured property or object.\r\n * @param condition The function to validate the rule.\r\n * Will be called with two arguments, the property value and the object.\r\n * Should return a boolean or a Promise that resolves to a boolean.\r\n */\r\n FluentRules.prototype.satisfies = function (condition, config) {\r\n return new FluentRuleCustomizer(this.property, condition, config, this.fluentEnsure, this, this.parsers);\r\n };\r\n /**\r\n * Applies a rule by name.\r\n * @param name The name of the custom or standard rule.\r\n * @param args The rule's arguments.\r\n */\r\n FluentRules.prototype.satisfiesRule = function (name) {\r\n var _this = this;\r\n var args = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n args[_i - 1] = arguments[_i];\r\n }\r\n var rule = FluentRules.customRules[name];\r\n if (!rule) {\r\n // standard rule?\r\n rule = this[name];\r\n if (rule instanceof Function) {\r\n return rule.call.apply(rule, [this].concat(args));\r\n }\r\n throw new Error(\"Rule with name \\\"\" + name + \"\\\" does not exist.\");\r\n }\r\n var config = rule.argsToConfig ? rule.argsToConfig.apply(rule, args) : undefined;\r\n return this.satisfies(function (value, obj) {\r\n var _a;\r\n return (_a = rule.condition).call.apply(_a, [_this, value, obj].concat(args));\r\n }, config)\r\n .withMessageKey(name);\r\n };\r\n /**\r\n * Applies the \"required\" rule to the property.\r\n * The value cannot be null, undefined or whitespace.\r\n */\r\n FluentRules.prototype.required = function () {\r\n return this.satisfies(function (value) {\r\n return value !== null\r\n && value !== undefined\r\n && !(isString(value) && !/\\S/.test(value));\r\n }).withMessageKey('required');\r\n };\r\n /**\r\n * Applies the \"matches\" rule to the property.\r\n * Value must match the specified regular expression.\r\n * null, undefined and empty-string values are considered valid.\r\n */\r\n FluentRules.prototype.matches = function (regex) {\r\n return this.satisfies(function (value) { return value === null || value === undefined || value.length === 0 || regex.test(value); })\r\n .withMessageKey('matches');\r\n };\r\n /**\r\n * Applies the \"email\" rule to the property.\r\n * null, undefined and empty-string values are considered valid.\r\n */\r\n FluentRules.prototype.email = function () {\r\n // regex from https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address\r\n /* tslint:disable:max-line-length */\r\n return this.matches(/^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/)\r\n /* tslint:enable:max-line-length */\r\n .withMessageKey('email');\r\n };\r\n /**\r\n * Applies the \"minLength\" STRING validation rule to the property.\r\n * null, undefined and empty-string values are considered valid.\r\n */\r\n FluentRules.prototype.minLength = function (length) {\r\n return this.satisfies(function (value) { return value === null || value === undefined || value.length === 0 || value.length >= length; }, { length: length })\r\n .withMessageKey('minLength');\r\n };\r\n /**\r\n * Applies the \"maxLength\" STRING validation rule to the property.\r\n * null, undefined and empty-string values are considered valid.\r\n */\r\n FluentRules.prototype.maxLength = function (length) {\r\n return this.satisfies(function (value) { return value === null || value === undefined || value.length === 0 || value.length <= length; }, { length: length })\r\n .withMessageKey('maxLength');\r\n };\r\n /**\r\n * Applies the \"minItems\" ARRAY validation rule to the property.\r\n * null and undefined values are considered valid.\r\n */\r\n FluentRules.prototype.minItems = function (count) {\r\n return this.satisfies(function (value) { return value === null || value === undefined || value.length >= count; }, { count: count })\r\n .withMessageKey('minItems');\r\n };\r\n /**\r\n * Applies the \"maxItems\" ARRAY validation rule to the property.\r\n * null and undefined values are considered valid.\r\n */\r\n FluentRules.prototype.maxItems = function (count) {\r\n return this.satisfies(function (value) { return value === null || value === undefined || value.length <= count; }, { count: count })\r\n .withMessageKey('maxItems');\r\n };\r\n /**\r\n * Applies the \"min\" NUMBER validation rule to the property.\r\n * Value must be greater than or equal to the specified constraint.\r\n * null and undefined values are considered valid.\r\n */\r\n FluentRules.prototype.min = function (constraint) {\r\n return this.satisfies(function (value) { return value === null || value === undefined || value >= constraint; }, { constraint: constraint })\r\n .withMessageKey('min');\r\n };\r\n /**\r\n * Applies the \"max\" NUMBER validation rule to the property.\r\n * Value must be less than or equal to the specified constraint.\r\n * null and undefined values are considered valid.\r\n */\r\n FluentRules.prototype.max = function (constraint) {\r\n return this.satisfies(function (value) { return value === null || value === undefined || value <= constraint; }, { constraint: constraint })\r\n .withMessageKey('max');\r\n };\r\n /**\r\n * Applies the \"range\" NUMBER validation rule to the property.\r\n * Value must be between or equal to the specified min and max.\r\n * null and undefined values are considered valid.\r\n */\r\n FluentRules.prototype.range = function (min, max) {\r\n return this.satisfies(function (value) { return value === null || value === undefined || (value >= min && value <= max); }, { min: min, max: max })\r\n .withMessageKey('range');\r\n };\r\n /**\r\n * Applies the \"between\" NUMBER validation rule to the property.\r\n * Value must be between but not equal to the specified min and max.\r\n * null and undefined values are considered valid.\r\n */\r\n FluentRules.prototype.between = function (min, max) {\r\n return this.satisfies(function (value) { return value === null || value === undefined || (value > min && value < max); }, { min: min, max: max })\r\n .withMessageKey('between');\r\n };\r\n /**\r\n * Applies the \"equals\" validation rule to the property.\r\n * null and undefined values are considered valid.\r\n */\r\n FluentRules.prototype.equals = function (expectedValue) {\r\n return this.satisfies(function (value) { return value === null || value === undefined || value === '' || value === expectedValue; }, { expectedValue: expectedValue })\r\n .withMessageKey('equals');\r\n };\r\n FluentRules.customRules = {};\r\n return FluentRules;\r\n}());\r\n/**\r\n * Part of the fluent rule API. Enables targeting properties and objects with rules.\r\n */\r\nvar FluentEnsure = /** @class */ (function () {\r\n function FluentEnsure(parsers) {\r\n this.parsers = parsers;\r\n /**\r\n * Rules that have been defined using the fluent API.\r\n */\r\n this.rules = [];\r\n }\r\n /**\r\n * Target a property with validation rules.\r\n * @param property The property to target. Can be the property name or a property accessor\r\n * function.\r\n */\r\n FluentEnsure.prototype.ensure = function (property) {\r\n this.assertInitialized();\r\n var name = this.parsers.property.parse(property);\r\n var fluentRules = new FluentRules(this, this.parsers, { name: name, displayName: null });\r\n return this.mergeRules(fluentRules, name);\r\n };\r\n /**\r\n * Targets an object with validation rules.\r\n */\r\n FluentEnsure.prototype.ensureObject = function () {\r\n this.assertInitialized();\r\n var fluentRules = new FluentRules(this, this.parsers, { name: null, displayName: null });\r\n return this.mergeRules(fluentRules, null);\r\n };\r\n /**\r\n * Applies the rules to a class or object, making them discoverable by the StandardValidator.\r\n * @param target A class or object.\r\n */\r\n FluentEnsure.prototype.on = function (target) {\r\n Rules.set(target, this.rules);\r\n return this;\r\n };\r\n /**\r\n * Adds a rule definition to the sequenced ruleset.\r\n * @internal\r\n */\r\n FluentEnsure.prototype._addRule = function (rule) {\r\n while (this.rules.length < rule.sequence + 1) {\r\n this.rules.push([]);\r\n }\r\n this.rules[rule.sequence].push(rule);\r\n };\r\n FluentEnsure.prototype.assertInitialized = function () {\r\n if (this.parsers) {\r\n return;\r\n }\r\n throw new Error(\"Did you forget to add \\\".plugin('aurelia-validation')\\\" to your main.js?\");\r\n };\r\n FluentEnsure.prototype.mergeRules = function (fluentRules, propertyName) {\r\n // tslint:disable-next-line:triple-equals | Use loose equality for property keys\r\n var existingRules = this.rules.find(function (r) { return r.length > 0 && r[0].property.name == propertyName; });\r\n if (existingRules) {\r\n var rule = existingRules[existingRules.length - 1];\r\n fluentRules.sequence = rule.sequence;\r\n if (rule.property.displayName !== null) {\r\n fluentRules = fluentRules.displayName(rule.property.displayName);\r\n }\r\n }\r\n return fluentRules;\r\n };\r\n return FluentEnsure;\r\n}());\r\n/**\r\n * Fluent rule definition API.\r\n */\r\nvar ValidationRules = /** @class */ (function () {\r\n function ValidationRules() {\r\n }\r\n ValidationRules.initialize = function (messageParser, propertyParser) {\r\n this.parsers = {\r\n message: messageParser,\r\n property: propertyParser\r\n };\r\n };\r\n /**\r\n * Target a property with validation rules.\r\n * @param property The property to target. Can be the property name or a property accessor function.\r\n */\r\n ValidationRules.ensure = function (property) {\r\n return new FluentEnsure(ValidationRules.parsers).ensure(property);\r\n };\r\n /**\r\n * Targets an object with validation rules.\r\n */\r\n ValidationRules.ensureObject = function () {\r\n return new FluentEnsure(ValidationRules.parsers).ensureObject();\r\n };\r\n /**\r\n * Defines a custom rule.\r\n * @param name The name of the custom rule. Also serves as the message key.\r\n * @param condition The rule function.\r\n * @param message The message expression\r\n * @param argsToConfig A function that maps the rule's arguments to a \"config\"\r\n * object that can be used when evaluating the message expression.\r\n */\r\n ValidationRules.customRule = function (name, condition, message, argsToConfig) {\r\n validationMessages[name] = message;\r\n FluentRules.customRules[name] = { condition: condition, argsToConfig: argsToConfig };\r\n };\r\n /**\r\n * Returns rules with the matching tag.\r\n * @param rules The rules to search.\r\n * @param tag The tag to search for.\r\n */\r\n ValidationRules.taggedRules = function (rules, tag) {\r\n return rules.map(function (x) { return x.filter(function (r) { return r.tag === tag; }); });\r\n };\r\n /**\r\n * Returns rules that have no tag.\r\n * @param rules The rules to search.\r\n */\r\n ValidationRules.untaggedRules = function (rules) {\r\n return rules.map(function (x) { return x.filter(function (r) { return r.tag === undefined; }); });\r\n };\r\n /**\r\n * Removes the rules from a class or object.\r\n * @param target A class or object.\r\n */\r\n ValidationRules.off = function (target) {\r\n Rules.unset(target);\r\n };\r\n return ValidationRules;\r\n}());\n\n// Exports\r\n/**\r\n * Aurelia Validation Configuration API\r\n */\r\nvar AureliaValidationConfiguration = /** @class */ (function () {\r\n function AureliaValidationConfiguration() {\r\n this.validatorType = StandardValidator;\r\n }\r\n /**\r\n * Use a custom Validator implementation.\r\n */\r\n AureliaValidationConfiguration.prototype.customValidator = function (type) {\r\n this.validatorType = type;\r\n };\r\n /**\r\n * Applies the configuration.\r\n */\r\n AureliaValidationConfiguration.prototype.apply = function (container) {\r\n var validator = container.get(this.validatorType);\r\n container.registerInstance(Validator, validator);\r\n };\r\n return AureliaValidationConfiguration;\r\n}());\r\n/**\r\n * Configures the plugin.\r\n */\r\nfunction configure(\r\n// tslint:disable-next-line:ban-types\r\nframeworkConfig, callback) {\r\n // the fluent rule definition API needs the parser to translate messages\r\n // to interpolation expressions.\r\n var messageParser = frameworkConfig.container.get(ValidationMessageParser);\r\n var propertyParser = frameworkConfig.container.get(PropertyAccessorParser);\r\n ValidationRules.initialize(messageParser, propertyParser);\r\n // configure...\r\n var config = new AureliaValidationConfiguration();\r\n if (callback instanceof Function) {\r\n callback(config);\r\n }\r\n config.apply(frameworkConfig.container);\r\n // globalize the behaviors.\r\n if (frameworkConfig.globalResources) {\r\n frameworkConfig.globalResources(ValidateBindingBehavior, ValidateManuallyBindingBehavior, ValidateOnBlurBindingBehavior, ValidateOnChangeBindingBehavior, ValidateOnChangeOrBlurBindingBehavior, ValidationErrorsCustomAttribute, ValidationRendererCustomAttribute);\r\n }\r\n}\n\nexport { AureliaValidationConfiguration, configure, getTargetDOMElement, getPropertyInfo, PropertyAccessorParser, getAccessorExpression, ValidateBindingBehavior, ValidateManuallyBindingBehavior, ValidateOnBlurBindingBehavior, ValidateOnChangeBindingBehavior, ValidateOnChangeOrBlurBindingBehavior, ValidateEvent, ValidateResult, validateTrigger, ValidationController, ValidationControllerFactory, ValidationErrorsCustomAttribute, ValidationRendererCustomAttribute, Validator, Rules, StandardValidator, validationMessages, ValidationMessageProvider, ValidationMessageParser, MessageExpressionValidator, FluentRuleCustomizer, FluentRules, FluentEnsure, ValidationRules };\n"],"sourceRoot":""}