Skip to content

Commit

Permalink
chore(all): prepare release 1.0.0-beta.1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Dec 9, 2016
1 parent c2a2ae1 commit 79f6dd9
Show file tree
Hide file tree
Showing 164 changed files with 1,951 additions and 3,770 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": "0.14.0",
"version": "1.0.0-beta.1.0.0",
"description": "Validation for Aurelia applications",
"keywords": [
"aurelia",
Expand Down
5 changes: 4 additions & 1 deletion dist/amd/aurelia-validation.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
export * from './controller-validate-result';
export * from './property-info';
export * from './validate-binding-behavior';
export * from './validate-instruction';
export * from './validate-result';
export * from './validate-trigger';
export * from './validation-controller';
export * from './validation-controller-factory';
export * from './validation-error';
export * from './validation-errors-custom-attribute';
export * from './validation-renderer-custom-attribute';
export * from './validation-renderer';
Expand Down
5 changes: 3 additions & 2 deletions dist/amd/aurelia-validation.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// Exports
define(["require", "exports", './validate-binding-behavior', './validate-trigger', './validation-controller', './validation-controller-factory', './validation-error', './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, validate_binding_behavior_1, validate_trigger_1, validation_controller_1, validation_controller_factory_1, validation_error_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", "./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) {
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
__export(property_info_1);
__export(validate_binding_behavior_1);
__export(validate_result_1);
__export(validate_trigger_1);
__export(validation_controller_1);
__export(validation_controller_factory_1);
__export(validation_error_1);
__export(validation_errors_custom_attribute_1);
__export(validation_renderer_custom_attribute_1);
__export(validator_1);
Expand Down
19 changes: 19 additions & 0 deletions dist/amd/controller-validate-result.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ValidateResult } from './validate-result';
import { ValidateInstruction } from './validate-instruction';
/**
* The result of a call to the validation controller's validate method.
*/
export interface ControllerValidateResult {
/**
* Whether validation passed.
*/
valid: boolean;
/**
* The validation result of every rule that was evaluated.
*/
results: ValidateResult[];
/**
* The instruction passed to the controller's validate method.
*/
instruction?: ValidateInstruction;
}
3 changes: 3 additions & 0 deletions dist/amd/controller-validate-result.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
define(["require", "exports"], function (require, exports) {
"use strict";
});
8 changes: 4 additions & 4 deletions dist/amd/implementation/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ define(["require", "exports"], function (require, exports) {
Rules.get = function (target) {
return target[Rules.key] || null;
};
/**
* The name of the property that stores the rules.
*/
Rules.key = '__rules__';
return Rules;
}());
/**
* The name of the property that stores the rules.
*/
Rules.key = '__rules__';
exports.Rules = Rules;
});
10 changes: 5 additions & 5 deletions dist/amd/implementation/standard-validator.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ViewResources } from 'aurelia-templating';
import { Validator } from '../validator';
import { ValidationError } from '../validation-error';
import { ValidateResult } from '../validate-result';
import { Rule } from './rule';
import { ValidationMessageProvider } from './validation-messages';
/**
* Validates.
* Responsible for validating objects and properties.
*/
export declare class StandardValidator extends Validator {
static inject: (typeof ValidationMessageProvider | typeof ViewResources)[];
static inject: (typeof ViewResources | typeof ValidationMessageProvider)[];
private messageProvider;
private lookupFunctions;
private getDisplayName;
Expand All @@ -20,21 +20,21 @@ export declare class StandardValidator extends Validator {
* @param rules Optional. If unspecified, the rules will be looked up using the metadata
* for the object created by ValidationRules....on(class/object)
*/
validateProperty(object: any, propertyName: string, rules?: any): Promise<ValidationError[]>;
validateProperty(object: any, propertyName: string, rules?: any): Promise<ValidateResult[]>;
/**
* Validates all rules for specified object and it's properties.
* @param object The object to validate.
* @param rules Optional. If unspecified, the rules will be looked up using the metadata
* for the object created by ValidationRules....on(class/object)
*/
validateObject(object: any, rules?: any): Promise<ValidationError[]>;
validateObject(object: any, rules?: any): Promise<ValidateResult[]>;
/**
* Determines whether a rule exists in a set of rules.
* @param rules The rules to search.
* @parem rule The rule to find.
*/
ruleExists(rules: Rule<any, any>[][], rule: Rule<any, any>): boolean;
private getMessage(rule, object, value);
private validateRuleSequence(object, propertyName, ruleSequence, sequence);
private validateRuleSequence(object, propertyName, ruleSequence, sequence, results);
private validate(object, propertyName, rules);
}
41 changes: 21 additions & 20 deletions dist/amd/implementation/standard-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var __extends = (this && this.__extends) || function (d, b) {
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
define(["require", "exports", 'aurelia-templating', '../validator', '../validation-error', './rules', './validation-messages'], function (require, exports, aurelia_templating_1, validator_1, validation_error_1, rules_1, validation_messages_1) {
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";
/**
* Validates.
Expand All @@ -12,10 +12,11 @@ define(["require", "exports", 'aurelia-templating', '../validator', '../validati
var StandardValidator = (function (_super) {
__extends(StandardValidator, _super);
function StandardValidator(messageProvider, resources) {
_super.call(this);
this.messageProvider = messageProvider;
this.lookupFunctions = resources.lookupFunctions;
this.getDisplayName = messageProvider.getDisplayName.bind(messageProvider);
var _this = _super.call(this) || this;
_this.messageProvider = messageProvider;
_this.lookupFunctions = resources.lookupFunctions;
_this.getDisplayName = messageProvider.getDisplayName.bind(messageProvider);
return _this;
}
/**
* Validates the specified property.
Expand Down Expand Up @@ -53,8 +54,8 @@ define(["require", "exports", 'aurelia-templating', '../validator', '../validati
StandardValidator.prototype.getMessage = function (rule, object, value) {
var expression = rule.message || this.messageProvider.getMessage(rule.messageKey);
var _a = rule.property, propertyName = _a.name, displayName = _a.displayName;
if (displayName === null && propertyName !== null) {
displayName = this.messageProvider.getDisplayName(propertyName);
if (propertyName !== null) {
displayName = this.messageProvider.getDisplayName(propertyName, displayName);
}
var overrideContext = {
$displayName: displayName,
Expand All @@ -66,15 +67,15 @@ define(["require", "exports", 'aurelia-templating', '../validator', '../validati
};
return expression.evaluate({ bindingContext: object, overrideContext: overrideContext }, this.lookupFunctions);
};
StandardValidator.prototype.validateRuleSequence = function (object, propertyName, ruleSequence, sequence) {
StandardValidator.prototype.validateRuleSequence = function (object, propertyName, ruleSequence, sequence, results) {
var _this = this;
// are we validating all properties or a single property?
var validateAllProperties = propertyName === null || propertyName === undefined;
var rules = ruleSequence[sequence];
var errors = [];
var allValid = true;
// validate each rule.
var promises = [];
var _loop_1 = function(i) {
var _loop_1 = function (i) {
var rule = rules[i];
// is the rule related to the property we're validating.
if (!validateAllProperties && rule.property.name !== propertyName) {
Expand All @@ -90,11 +91,11 @@ define(["require", "exports", 'aurelia-templating', '../validator', '../validati
if (!(promiseOrBoolean instanceof Promise)) {
promiseOrBoolean = Promise.resolve(promiseOrBoolean);
}
promises.push(promiseOrBoolean.then(function (isValid) {
if (!isValid) {
var message = _this.getMessage(rule, object, value);
errors.push(new validation_error_1.ValidationError(rule, message, object, rule.property.name));
}
promises.push(promiseOrBoolean.then(function (valid) {
var message = valid ? null : _this.getMessage(rule, object, value);
results.push(new validate_result_1.ValidateResult(rule, object, rule.property.name, valid, message));
allValid = allValid && valid;
return valid;
}));
};
for (var i = 0; i < rules.length; i++) {
Expand All @@ -103,10 +104,10 @@ define(["require", "exports", 'aurelia-templating', '../validator', '../validati
return Promise.all(promises)
.then(function () {
sequence++;
if (errors.length === 0 && sequence < ruleSequence.length) {
return _this.validateRuleSequence(object, propertyName, ruleSequence, sequence);
if (allValid && sequence < ruleSequence.length) {
return _this.validateRuleSequence(object, propertyName, ruleSequence, sequence, results);
}
return errors;
return results;
});
};
StandardValidator.prototype.validate = function (object, propertyName, rules) {
Expand All @@ -119,10 +120,10 @@ define(["require", "exports", 'aurelia-templating', '../validator', '../validati
if (!rules) {
return Promise.resolve([]);
}
return this.validateRuleSequence(object, propertyName, rules, 0);
return this.validateRuleSequence(object, propertyName, rules, 0, []);
};
StandardValidator.inject = [validation_messages_1.ValidationMessageProvider, aurelia_templating_1.ViewResources];
return StandardValidator;
}(validator_1.Validator));
StandardValidator.inject = [validation_messages_1.ValidationMessageProvider, aurelia_templating_1.ViewResources];
exports.StandardValidator = StandardValidator;
});
6 changes: 3 additions & 3 deletions dist/amd/implementation/validation-messages.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export declare class ValidationMessageProvider {
*/
getMessage(key: string): Expression;
/**
* When a display name is not provided, this method is used to formulate
* a display name using the property name.
* Formulates a property display name using the property name and the configured
* displayName (if provided).
* Override this with your own custom logic.
* @param propertyName The property name.
*/
getDisplayName(propertyName: string): string;
getDisplayName(propertyName: string, displayName: string | null | undefined): string;
}
13 changes: 8 additions & 5 deletions dist/amd/implementation/validation-messages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(["require", "exports", './validation-parser'], function (require, exports, validation_parser_1) {
define(["require", "exports", "./validation-parser"], function (require, exports, validation_parser_1) {
"use strict";
/**
* Dictionary of validation messages. [messageKey]: messageExpression
Expand Down Expand Up @@ -39,19 +39,22 @@ define(["require", "exports", './validation-parser'], function (require, exports
return this.parser.parseMessage(message);
};
/**
* When a display name is not provided, this method is used to formulate
* a display name using the property name.
* Formulates a property display name using the property name and the configured
* displayName (if provided).
* Override this with your own custom logic.
* @param propertyName The property name.
*/
ValidationMessageProvider.prototype.getDisplayName = function (propertyName) {
ValidationMessageProvider.prototype.getDisplayName = function (propertyName, displayName) {
if (displayName !== null && displayName !== undefined) {
return displayName;
}
// split on upper-case letters.
var words = propertyName.split(/(?=[A-Z])/).join(' ');
// capitalize first letter.
return words.charAt(0).toUpperCase() + words.slice(1);
};
ValidationMessageProvider.inject = [validation_parser_1.ValidationParser];
return ValidationMessageProvider;
}());
ValidationMessageProvider.inject = [validation_parser_1.ValidationParser];
exports.ValidationMessageProvider = ValidationMessageProvider;
});
9 changes: 5 additions & 4 deletions dist/amd/implementation/validation-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var __extends = (this && this.__extends) || function (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) {
define(["require", "exports", "aurelia-binding", "aurelia-templating", "./util", "aurelia-logging"], function (require, exports, aurelia_binding_1, aurelia_templating_1, util_1, LogManager) {
"use strict";
var ValidationParser = (function () {
function ValidationParser(parser, bindinqLanguage) {
Expand Down Expand Up @@ -57,15 +57,16 @@ define(["require", "exports", 'aurelia-binding', 'aurelia-templating', './util',
}
return this.parser.parse(match[1]);
};
ValidationParser.inject = [aurelia_binding_1.Parser, aurelia_templating_1.BindingLanguage];
return ValidationParser;
}());
ValidationParser.inject = [aurelia_binding_1.Parser, aurelia_templating_1.BindingLanguage];
exports.ValidationParser = ValidationParser;
var MessageExpressionValidator = (function (_super) {
__extends(MessageExpressionValidator, _super);
function MessageExpressionValidator(originalMessage) {
_super.call(this, []);
this.originalMessage = originalMessage;
var _this = _super.call(this, []) || this;
_this.originalMessage = originalMessage;
return _this;
}
MessageExpressionValidator.validate = function (expression, originalMessage) {
var visitor = new MessageExpressionValidator(originalMessage);
Expand Down
7 changes: 6 additions & 1 deletion dist/amd/implementation/validation-rules.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ export declare class FluentRules<TObject, TValue> {
argsToConfig?: (...args: any[]) => any;
};
};
/**
* Current rule sequence number. Used to postpone evaluation of rules until rules
* with lower sequence number have successfully validated. The "then" fluent API method
* manages this property, there's usually no need to set it directly.
*/
sequence: number;
constructor(fluentEnsure: FluentEnsure<TObject>, parser: ValidationParser, property: RuleProperty);
/**
* Sets the display name of the ensured property.
Expand Down Expand Up @@ -191,7 +197,6 @@ export declare class FluentEnsure<TObject> {
* Rules that have been defined using the fluent API.
*/
rules: Rule<TObject, any>[][];
_sequence: number;
constructor(parser: ValidationParser);
/**
* Target a property with validation rules.
Expand Down
Loading

0 comments on commit 79f6dd9

Please sign in to comment.