Skip to content

Commit

Permalink
chore(all): prepare release 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Mar 1, 2017
1 parent f9ec842 commit 87da3ca
Show file tree
Hide file tree
Showing 138 changed files with 947 additions and 638 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-validation",
"version": "1.0.0-beta.1.0.1",
"version": "1.0.0",
"description": "Validation for Aurelia applications",
"keywords": [
"aurelia",
Expand Down
3 changes: 2 additions & 1 deletion dist/amd/aurelia-validation.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './controller-validate-result';
export * from './get-target-dom-element';
export * from './property-info';
export * from './validate-binding-behavior';
export * from './validate-instruction';
Expand Down Expand Up @@ -39,5 +40,5 @@ export declare class AureliaValidationConfiguration {
*/
export declare function configure(frameworkConfig: {
container: Container;
globalResources: (...resources: string[]) => any;
globalResources?: (...resources: string[]) => any;
}, callback?: (config: AureliaValidationConfiguration) => void): void;
10 changes: 7 additions & 3 deletions dist/amd/aurelia-validation.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Exports
define(["require", "exports", "./property-info", "./validate-binding-behavior", "./validate-result", "./validate-trigger", "./validation-controller", "./validation-controller-factory", "./validation-errors-custom-attribute", "./validation-renderer-custom-attribute", "./validator", "./implementation/rules", "./implementation/standard-validator", "./implementation/validation-messages", "./implementation/validation-parser", "./implementation/validation-rules", "./validator", "./implementation/standard-validator", "./implementation/validation-parser", "./implementation/validation-rules"], function (require, exports, property_info_1, validate_binding_behavior_1, validate_result_1, validate_trigger_1, validation_controller_1, validation_controller_factory_1, validation_errors_custom_attribute_1, validation_renderer_custom_attribute_1, validator_1, rules_1, standard_validator_1, validation_messages_1, validation_parser_1, validation_rules_1, validator_2, standard_validator_2, validation_parser_2, validation_rules_2) {
define(["require", "exports", "./get-target-dom-element", "./property-info", "./validate-binding-behavior", "./validate-result", "./validate-trigger", "./validation-controller", "./validation-controller-factory", "./validation-errors-custom-attribute", "./validation-renderer-custom-attribute", "./validator", "./implementation/rules", "./implementation/standard-validator", "./implementation/validation-messages", "./implementation/validation-parser", "./implementation/validation-rules", "aurelia-pal", "./validator", "./implementation/standard-validator", "./implementation/validation-parser", "./implementation/validation-rules"], function (require, exports, get_target_dom_element_1, property_info_1, validate_binding_behavior_1, validate_result_1, validate_trigger_1, validation_controller_1, validation_controller_factory_1, validation_errors_custom_attribute_1, validation_renderer_custom_attribute_1, validator_1, rules_1, standard_validator_1, validation_messages_1, validation_parser_1, validation_rules_1, aurelia_pal_1, validator_2, standard_validator_2, validation_parser_2, validation_rules_2) {
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(get_target_dom_element_1);
__export(property_info_1);
__export(validate_binding_behavior_1);
__export(validate_result_1);
Expand Down Expand Up @@ -46,7 +48,7 @@ define(["require", "exports", "./property-info", "./validate-binding-behavior",
*/
function configure(frameworkConfig, callback) {
// the fluent rule definition API needs the parser to translate messages
// to interpolation expressions.
// to interpolation expressions.
var parser = frameworkConfig.container.get(validation_parser_2.ValidationParser);
validation_rules_2.ValidationRules.initialize(parser);
// configure...
Expand All @@ -56,7 +58,9 @@ define(["require", "exports", "./property-info", "./validate-binding-behavior",
}
config.apply(frameworkConfig.container);
// globalize the behaviors.
frameworkConfig.globalResources('./validate-binding-behavior', './validation-errors-custom-attribute', './validation-renderer-custom-attribute');
if (frameworkConfig.globalResources) {
frameworkConfig.globalResources(aurelia_pal_1.PLATFORM.moduleName('./validate-binding-behavior'), aurelia_pal_1.PLATFORM.moduleName('./validation-errors-custom-attribute'), aurelia_pal_1.PLATFORM.moduleName('./validation-renderer-custom-attribute'));
}
}
exports.configure = configure;
});
1 change: 1 addition & 0 deletions dist/amd/controller-validate-result.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
});
7 changes: 7 additions & 0 deletions dist/amd/get-target-dom-element.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Gets the DOM element associated with the data-binding. Most of the time it's
* the binding.target but sometimes binding.target is an aurelia custom element,
* or custom attribute which is a javascript "class" instance, so we need to use
* the controller's container to retrieve the actual DOM element.
*/
export declare function getTargetDOMElement(binding: any, view: any): Element;
31 changes: 31 additions & 0 deletions dist/amd/get-target-dom-element.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
define(["require", "exports", "aurelia-pal"], function (require, exports, aurelia_pal_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Gets the DOM element associated with the data-binding. Most of the time it's
* the binding.target but sometimes binding.target is an aurelia custom element,
* or custom attribute which is a javascript "class" instance, so we need to use
* the controller's container to retrieve the actual DOM element.
*/
function getTargetDOMElement(binding, view) {
var target = binding.target;
// DOM element
if (target instanceof Element) {
return target;
}
// custom element or custom attribute
// tslint:disable-next-line:prefer-const
for (var i = 0, ii = view.controllers.length; i < ii; i++) {
var controller = view.controllers[i];
if (controller.viewModel === target) {
var element = controller.container.get(aurelia_pal_1.DOM.Element);
if (element) {
return element;
}
throw new Error("Unable to locate target element for \"" + binding.sourceExpression + "\".");
}
}
throw new Error("Unable to locate target element for \"" + binding.sourceExpression + "\".");
}
exports.getTargetDOMElement = getTargetDOMElement;
});
7 changes: 3 additions & 4 deletions dist/amd/implementation/rule.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Expression } from 'aurelia-binding';
export declare type ValidationDisplayNameAccessor = () => string;
/**
* Information related to a property that is the subject of validation.
*/
Expand All @@ -10,7 +11,7 @@ export interface RuleProperty {
/**
* The displayName of the property (or object).
*/
displayName: string | null;
displayName: string | ValidationDisplayNameAccessor | null;
}
/**
* A rule definition. Associations a rule with a property or object.
Expand All @@ -19,9 +20,7 @@ export interface Rule<TObject, TValue> {
property: RuleProperty;
condition: (value: TValue, object?: TObject) => boolean | Promise<boolean>;
config: Object;
when: {
(object: TObject): boolean;
} | null;
when: ((object: TObject) => boolean) | null;
messageKey: string;
message: Expression | null;
sequence: number;
Expand Down
1 change: 1 addition & 0 deletions dist/amd/implementation/rule.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
});
1 change: 1 addition & 0 deletions dist/amd/implementation/rules.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Sets, unsets and retrieves rules on an object or constructor function.
*/
Expand Down
19 changes: 14 additions & 5 deletions dist/amd/implementation/standard-validator.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
define(["require", "exports", "aurelia-templating", "../validator", "../validate-result", "./rules", "./validation-messages"], function (require, exports, aurelia_templating_1, validator_1, validate_result_1, rules_1, validation_messages_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Validates.
* Responsible for validating objects and properties.
Expand Down Expand Up @@ -53,6 +59,7 @@ define(["require", "exports", "aurelia-templating", "../validator", "../validate
};
StandardValidator.prototype.getMessage = function (rule, object, value) {
var expression = rule.message || this.messageProvider.getMessage(rule.messageKey);
// tslint:disable-next-line:prefer-const
var _a = rule.property, propertyName = _a.name, displayName = _a.displayName;
if (propertyName !== null) {
displayName = this.messageProvider.getDisplayName(propertyName, displayName);
Expand All @@ -63,6 +70,8 @@ define(["require", "exports", "aurelia-templating", "../validator", "../validate
$value: value,
$object: object,
$config: rule.config,
// returns the name of a given property, given just the property name (irrespective of the property's displayName)
// split on capital letters, first letter ensured to be capitalized
$getDisplayName: this.getDisplayName
};
return expression.evaluate({ bindingContext: object, overrideContext: overrideContext }, this.lookupFunctions);
Expand Down
1 change: 1 addition & 0 deletions dist/amd/implementation/util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function isString(value) {
return Object.prototype.toString.call(value) === '[object String]';
}
Expand Down
2 changes: 1 addition & 1 deletion dist/amd/implementation/validation-messages.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ export declare class ValidationMessageProvider {
* Override this with your own custom logic.
* @param propertyName The property name.
*/
getDisplayName(propertyName: string, displayName: string | null | undefined): string;
getDisplayName(propertyName: string, displayName?: string | null | Function): string;
}
3 changes: 2 additions & 1 deletion dist/amd/implementation/validation-messages.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
define(["require", "exports", "./validation-parser"], function (require, exports, validation_parser_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Dictionary of validation messages. [messageKey]: messageExpression
*/
Expand Down Expand Up @@ -46,7 +47,7 @@ define(["require", "exports", "./validation-parser"], function (require, exports
*/
ValidationMessageProvider.prototype.getDisplayName = function (propertyName, displayName) {
if (displayName !== null && displayName !== undefined) {
return displayName;
return (displayName instanceof Function) ? displayName() : displayName;
}
// split on upper-case letters.
var words = propertyName.split(/(?=[A-Z])/).join(' ');
Expand Down
4 changes: 1 addition & 3 deletions dist/amd/implementation/validation-parser.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Parser, Expression, AccessScope, Unparser } from 'aurelia-binding';
import { BindingLanguage } from 'aurelia-templating';
import { RuleProperty } from './rule';
export interface PropertyAccessor<TObject, TValue> {
(object: TObject): TValue;
}
export declare type PropertyAccessor<TObject, TValue> = (object: TObject) => TValue;
export declare class ValidationParser {
private parser;
private bindinqLanguage;
Expand Down
20 changes: 14 additions & 6 deletions dist/amd/implementation/validation-parser.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
define(["require", "exports", "aurelia-binding", "aurelia-templating", "./util", "aurelia-logging"], function (require, exports, aurelia_binding_1, aurelia_templating_1, util_1, LogManager) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ValidationParser = (function () {
function ValidationParser(parser, bindinqLanguage) {
this.parser = parser;
Expand Down Expand Up @@ -49,7 +55,9 @@ define(["require", "exports", "aurelia-binding", "aurelia-templating", "./util",
return new aurelia_binding_1.Conditional(new aurelia_binding_1.Binary('||', new aurelia_binding_1.Binary('===', part, this.nullExpression), new aurelia_binding_1.Binary('===', part, this.undefinedExpression)), this.emptyStringExpression, new aurelia_binding_1.CallMember(part, 'toString', []));
};
ValidationParser.prototype.getAccessorExpression = function (fn) {
var classic = /^function\s*\([$_\w\d]+\)\s*\{\s*(?:"use strict";)?\s*return\s+[$_\w\d]+\.([$_\w\d]+)\s*;?\s*\}$/;
/* tslint:disable:max-line-length */
var classic = /^function\s*\([$_\w\d]+\)\s*\{(?:\s*"use strict";)?\s*(?:[$_\w\d.['"\]+;]+)?\s*return\s+[$_\w\d]+\.([$_\w\d]+)\s*;?\s*\}$/;
/* tslint:enable:max-line-length */
var arrow = /^\(?[$_\w\d]+\)?\s*=>\s*[$_\w\d]+\.([$_\w\d]+)$/;
var match = classic.exec(fn) || arrow.exec(fn);
if (match === null) {
Expand Down
17 changes: 6 additions & 11 deletions dist/amd/implementation/validation-rules.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Rule, RuleProperty } from './rule';
import { ValidationParser, PropertyAccessor } from './validation-parser';
import { ValidationDisplayNameAccessor } from './rule';
/**
* Part of the fluent rule API. Enables customizing property rules.
*/
Expand All @@ -8,7 +9,7 @@ export declare class FluentRuleCustomizer<TObject, TValue> {
private fluentRules;
private parser;
private rule;
constructor(property: RuleProperty, condition: (value: TValue, object?: TObject) => boolean | Promise<boolean>, config: Object, fluentEnsure: FluentEnsure<TObject>, fluentRules: FluentRules<TObject, TValue>, parser: ValidationParser);
constructor(property: RuleProperty, condition: (value: TValue, object?: TObject) => boolean | Promise<boolean>, config: Object | undefined, fluentEnsure: FluentEnsure<TObject>, fluentRules: FluentRules<TObject, TValue>, parser: ValidationParser);
/**
* Validate subsequent rules after previously declared rules have
* been validated successfully. Use to postpone validation of costly
Expand Down Expand Up @@ -38,9 +39,7 @@ export declare class FluentRuleCustomizer<TObject, TValue> {
* Target a property with validation rules.
* @param property The property to target. Can be the property name or a property accessor function.
*/
ensure<TValue2>(subject: string | {
(model: TObject): TValue2;
}): FluentRules<TObject, TValue2>;
ensure<TValue2>(subject: string | ((model: TObject) => TValue2)): FluentRules<TObject, TValue2>;
/**
* Targets an object with validation rules.
*/
Expand All @@ -66,7 +65,7 @@ export declare class FluentRuleCustomizer<TObject, TValue> {
* @param name The name of the custom or standard rule.
* @param args The rule's arguments.
*/
satisfiesRule(name: string, ...args: any[]): FluentRuleCustomizer<TObject, TValue>;
satisfiesRule(name: string, ...args: any[]): any;
/**
* Applies the "required" rule to the property.
* The value cannot be null, undefined or whitespace.
Expand Down Expand Up @@ -132,7 +131,7 @@ export declare class FluentRules<TObject, TValue> {
/**
* Sets the display name of the ensured property.
*/
displayName(name: string): this;
displayName(name: string | ValidationDisplayNameAccessor | null): this;
/**
* Applies an ad-hoc rule function to the ensured property or object.
* @param condition The function to validate the rule.
Expand All @@ -145,7 +144,7 @@ export declare class FluentRules<TObject, TValue> {
* @param name The name of the custom or standard rule.
* @param args The rule's arguments.
*/
satisfiesRule(name: string, ...args: any[]): FluentRuleCustomizer<TObject, TValue>;
satisfiesRule(name: string, ...args: any[]): any;
/**
* Applies the "required" rule to the property.
* The value cannot be null, undefined or whitespace.
Expand Down Expand Up @@ -213,10 +212,6 @@ export declare class FluentEnsure<TObject> {
* @param target A class or object.
*/
on(target: any): this;
/**
* Adds a rule definition to the sequenced ruleset.
*/
_addRule(rule: Rule<TObject, any>): void;
private assertInitialized();
}
/**
Expand Down
4 changes: 3 additions & 1 deletion dist/amd/implementation/validation-rules.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
define(["require", "exports", "./util", "./rules", "./validation-messages"], function (require, exports, util_1, rules_1, validation_messages_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Part of the fluent rule API. Enables customizing property rules.
*/
Expand Down Expand Up @@ -345,6 +346,7 @@ define(["require", "exports", "./util", "./rules", "./validation-messages"], fun
};
/**
* Adds a rule definition to the sequenced ruleset.
* @internal
*/
FluentEnsure.prototype._addRule = function (rule) {
while (this.rules.length < rule.sequence + 1) {
Expand All @@ -356,7 +358,7 @@ define(["require", "exports", "./util", "./rules", "./validation-messages"], fun
if (this.parser) {
return;
}
throw new Error("Did you forget to add \".plugin('aurelia-validation)\" to your main.js?");
throw new Error("Did you forget to add \".plugin('aurelia-validation')\" to your main.js?");
};
return FluentEnsure;
}());
Expand Down
4 changes: 2 additions & 2 deletions dist/amd/property-info.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
define(["require", "exports", "aurelia-binding"], function (require, exports, aurelia_binding_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getObject(expression, objectExpression, source) {
var value = objectExpression.evaluate(source, null);
if (value === null || value === undefined || value instanceof Object) {
return value;
}
/* tslint:disable */
// tslint:disable-next-line:max-line-length
throw new Error("The '" + objectExpression + "' part of '" + expression + "' evaluates to " + value + " instead of an object, null or undefined.");
/* tslint:enable */
}
/**
* Retrieves the object and property name for the specified expression.
Expand Down
Loading

0 comments on commit 87da3ca

Please sign in to comment.