Skip to content

Commit 87da3ca

Browse files
chore(all): prepare release 1.0.0
1 parent f9ec842 commit 87da3ca

File tree

138 files changed

+947
-638
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+947
-638
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aurelia-validation",
3-
"version": "1.0.0-beta.1.0.1",
3+
"version": "1.0.0",
44
"description": "Validation for Aurelia applications",
55
"keywords": [
66
"aurelia",

dist/amd/aurelia-validation.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './controller-validate-result';
2+
export * from './get-target-dom-element';
23
export * from './property-info';
34
export * from './validate-binding-behavior';
45
export * from './validate-instruction';
@@ -39,5 +40,5 @@ export declare class AureliaValidationConfiguration {
3940
*/
4041
export declare function configure(frameworkConfig: {
4142
container: Container;
42-
globalResources: (...resources: string[]) => any;
43+
globalResources?: (...resources: string[]) => any;
4344
}, callback?: (config: AureliaValidationConfiguration) => void): void;

dist/amd/aurelia-validation.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Exports
2-
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) {
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) {
33
"use strict";
44
function __export(m) {
55
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
66
}
7+
Object.defineProperty(exports, "__esModule", { value: true });
8+
__export(get_target_dom_element_1);
79
__export(property_info_1);
810
__export(validate_binding_behavior_1);
911
__export(validate_result_1);
@@ -46,7 +48,7 @@ define(["require", "exports", "./property-info", "./validate-binding-behavior",
4648
*/
4749
function configure(frameworkConfig, callback) {
4850
// the fluent rule definition API needs the parser to translate messages
49-
// to interpolation expressions.
51+
// to interpolation expressions.
5052
var parser = frameworkConfig.container.get(validation_parser_2.ValidationParser);
5153
validation_rules_2.ValidationRules.initialize(parser);
5254
// configure...
@@ -56,7 +58,9 @@ define(["require", "exports", "./property-info", "./validate-binding-behavior",
5658
}
5759
config.apply(frameworkConfig.container);
5860
// globalize the behaviors.
59-
frameworkConfig.globalResources('./validate-binding-behavior', './validation-errors-custom-attribute', './validation-renderer-custom-attribute');
61+
if (frameworkConfig.globalResources) {
62+
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'));
63+
}
6064
}
6165
exports.configure = configure;
6266
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
define(["require", "exports"], function (require, exports) {
22
"use strict";
3+
Object.defineProperty(exports, "__esModule", { value: true });
34
});

dist/amd/get-target-dom-element.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Gets the DOM element associated with the data-binding. Most of the time it's
3+
* the binding.target but sometimes binding.target is an aurelia custom element,
4+
* or custom attribute which is a javascript "class" instance, so we need to use
5+
* the controller's container to retrieve the actual DOM element.
6+
*/
7+
export declare function getTargetDOMElement(binding: any, view: any): Element;

dist/amd/get-target-dom-element.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
define(["require", "exports", "aurelia-pal"], function (require, exports, aurelia_pal_1) {
2+
"use strict";
3+
Object.defineProperty(exports, "__esModule", { value: true });
4+
/**
5+
* Gets the DOM element associated with the data-binding. Most of the time it's
6+
* the binding.target but sometimes binding.target is an aurelia custom element,
7+
* or custom attribute which is a javascript "class" instance, so we need to use
8+
* the controller's container to retrieve the actual DOM element.
9+
*/
10+
function getTargetDOMElement(binding, view) {
11+
var target = binding.target;
12+
// DOM element
13+
if (target instanceof Element) {
14+
return target;
15+
}
16+
// custom element or custom attribute
17+
// tslint:disable-next-line:prefer-const
18+
for (var i = 0, ii = view.controllers.length; i < ii; i++) {
19+
var controller = view.controllers[i];
20+
if (controller.viewModel === target) {
21+
var element = controller.container.get(aurelia_pal_1.DOM.Element);
22+
if (element) {
23+
return element;
24+
}
25+
throw new Error("Unable to locate target element for \"" + binding.sourceExpression + "\".");
26+
}
27+
}
28+
throw new Error("Unable to locate target element for \"" + binding.sourceExpression + "\".");
29+
}
30+
exports.getTargetDOMElement = getTargetDOMElement;
31+
});

dist/amd/implementation/rule.d.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Expression } from 'aurelia-binding';
2+
export declare type ValidationDisplayNameAccessor = () => string;
23
/**
34
* Information related to a property that is the subject of validation.
45
*/
@@ -10,7 +11,7 @@ export interface RuleProperty {
1011
/**
1112
* The displayName of the property (or object).
1213
*/
13-
displayName: string | null;
14+
displayName: string | ValidationDisplayNameAccessor | null;
1415
}
1516
/**
1617
* A rule definition. Associations a rule with a property or object.
@@ -19,9 +20,7 @@ export interface Rule<TObject, TValue> {
1920
property: RuleProperty;
2021
condition: (value: TValue, object?: TObject) => boolean | Promise<boolean>;
2122
config: Object;
22-
when: {
23-
(object: TObject): boolean;
24-
} | null;
23+
when: ((object: TObject) => boolean) | null;
2524
messageKey: string;
2625
message: Expression | null;
2726
sequence: number;

dist/amd/implementation/rule.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
define(["require", "exports"], function (require, exports) {
22
"use strict";
3+
Object.defineProperty(exports, "__esModule", { value: true });
34
});

dist/amd/implementation/rules.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
define(["require", "exports"], function (require, exports) {
22
"use strict";
3+
Object.defineProperty(exports, "__esModule", { value: true });
34
/**
45
* Sets, unsets and retrieves rules on an object or constructor function.
56
*/

dist/amd/implementation/standard-validator.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
var __extends = (this && this.__extends) || function (d, b) {
2-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
3-
function __() { this.constructor = d; }
4-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
5-
};
1+
var __extends = (this && this.__extends) || (function () {
2+
var extendStatics = Object.setPrototypeOf ||
3+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
5+
return function (d, b) {
6+
extendStatics(d, b);
7+
function __() { this.constructor = d; }
8+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
9+
};
10+
})();
611
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) {
712
"use strict";
13+
Object.defineProperty(exports, "__esModule", { value: true });
814
/**
915
* Validates.
1016
* Responsible for validating objects and properties.
@@ -53,6 +59,7 @@ define(["require", "exports", "aurelia-templating", "../validator", "../validate
5359
};
5460
StandardValidator.prototype.getMessage = function (rule, object, value) {
5561
var expression = rule.message || this.messageProvider.getMessage(rule.messageKey);
62+
// tslint:disable-next-line:prefer-const
5663
var _a = rule.property, propertyName = _a.name, displayName = _a.displayName;
5764
if (propertyName !== null) {
5865
displayName = this.messageProvider.getDisplayName(propertyName, displayName);
@@ -63,6 +70,8 @@ define(["require", "exports", "aurelia-templating", "../validator", "../validate
6370
$value: value,
6471
$object: object,
6572
$config: rule.config,
73+
// returns the name of a given property, given just the property name (irrespective of the property's displayName)
74+
// split on capital letters, first letter ensured to be capitalized
6675
$getDisplayName: this.getDisplayName
6776
};
6877
return expression.evaluate({ bindingContext: object, overrideContext: overrideContext }, this.lookupFunctions);

0 commit comments

Comments
 (0)