Skip to content

Commit

Permalink
Added ValidationRegistry to register new validators
Browse files Browse the repository at this point in the history
  • Loading branch information
cneuwirt committed Apr 22, 2015
1 parent 038dada commit bd208bf
Show file tree
Hide file tree
Showing 11 changed files with 240 additions and 78 deletions.
42 changes: 33 additions & 9 deletions demo/mytodo/app/scripts/miruken-ng-bundle.js
Expand Up @@ -22,7 +22,7 @@ new function () { // closure
version: miruken.version,
parent: miruken,
imports: "miruken,miruken.callback,miruken.context,miruken.ioc,miruken.mvc",
exports: "$rootContext,Runner,Directive"
exports: "Runner,Directive,$rootContext"
});

eval(this.imports);
Expand Down Expand Up @@ -56,13 +56,15 @@ new function () { // closure
var parent = this.parent,
module = this.ngModule;
if (module instanceof Array) {
var name = String2.slice(this, 7, -1); // [base2.xyz]
var name = String2.slice(this, 7, -1); // [base2.xyz]
module = angular.module(name, module);
module.constant('$rootContext', $rootContext);
} else if (parent) {
module = parent.ngModule;
}
Object.defineProperty(this, 'ngModule', { value: module });
if (module) {
Object.defineProperty(this, 'ngModule', { value: module });
}
if (parent === base2) {
global[this.name] = this;
}
Expand Down Expand Up @@ -5081,7 +5083,7 @@ new function () { // closure
});

var extend = Base.extend;
Base.extend = function () {
Base.extend = Abstract.extend = function () {
return (function (base, args) {
var protocols, mixins, macros,
constraints = args;
Expand Down Expand Up @@ -5152,7 +5154,7 @@ new function () { // closure
};

var implement = Base.implement;
Base.implement = function (source) {
Base.implement = Abstract.implement = function (source) {
if ($isFunction(source)) {
source = source.prototype;
}
Expand Down Expand Up @@ -6636,7 +6638,8 @@ new function () { // closure
/**
* @class {Validation}
*/
var Validation = Base.extend({
var Validation = Base.extend(
$inferProperties, {
constructor: function (object, async, scope, results) {
var _asyncResults;
async = !!async;
Expand All @@ -6661,7 +6664,8 @@ new function () { // closure
/**
* @class {ValidationResult}
*/
var ValidationResult = Base.extend($inferProperties, {
var ValidationResult = Base.extend(
$inferProperties, {
constructor: function () {
var _errors, _summary;
this.extend({
Expand Down Expand Up @@ -6829,8 +6833,8 @@ new function () { // closure
name: "validate",
version: miruken.version,
parent: miruken,
imports: "miruken.callback,miruken.validate",
exports: "ValidateJsCallbackHandler,$required,$nested"
imports: "miruken,miruken.callback,miruken.validate",
exports: "ValidationRegistry,ValidateJsCallbackHandler,$required,$nested"
});

eval(this.imports);
Expand All @@ -6844,6 +6848,26 @@ new function () { // closure

validatejs.validators.nested = Undefined;

var $registerValidators = MetaMacro.extend({
apply: function (step, metadata, target, definition) {
if (step === MetaStep.Subclass || step === MetaStep.Implement) {
for (var name in definition) {
var validator = definition[name];
if ($isFunction(validator)) {
validatejs.validators[name] = validator;
}
}
}
},
shouldInherit: True,
isActive: True
});

/**
* @class {ValidationRegistry}
*/
var ValidationRegistry = Abstract.extend($registerValidators);

/**
* @class {ValidateJsCallbackHandler}
*/
Expand Down
34 changes: 28 additions & 6 deletions dist/miruken-bundle.js
Expand Up @@ -4807,7 +4807,7 @@ new function () { // closure
});

var extend = Base.extend;
Base.extend = function () {
Base.extend = Abstract.extend = function () {
return (function (base, args) {
var protocols, mixins, macros,
constraints = args;
Expand Down Expand Up @@ -4878,7 +4878,7 @@ new function () { // closure
};

var implement = Base.implement;
Base.implement = function (source) {
Base.implement = Abstract.implement = function (source) {
if ($isFunction(source)) {
source = source.prototype;
}
Expand Down Expand Up @@ -6132,7 +6132,8 @@ new function () { // closure
/**
* @class {Validation}
*/
var Validation = Base.extend({
var Validation = Base.extend(
$inferProperties, {
constructor: function (object, async, scope, results) {
var _asyncResults;
async = !!async;
Expand All @@ -6157,7 +6158,8 @@ new function () { // closure
/**
* @class {ValidationResult}
*/
var ValidationResult = Base.extend($inferProperties, {
var ValidationResult = Base.extend(
$inferProperties, {
constructor: function () {
var _errors, _summary;
this.extend({
Expand Down Expand Up @@ -6325,8 +6327,8 @@ new function () { // closure
name: "validate",
version: miruken.version,
parent: miruken,
imports: "miruken.callback,miruken.validate",
exports: "ValidateJsCallbackHandler,$required,$nested"
imports: "miruken,miruken.callback,miruken.validate",
exports: "ValidationRegistry,ValidateJsCallbackHandler,$required,$nested"
});

eval(this.imports);
Expand All @@ -6340,6 +6342,26 @@ new function () { // closure

validatejs.validators.nested = Undefined;

var $registerValidators = MetaMacro.extend({
apply: function (step, metadata, target, definition) {
if (step === MetaStep.Subclass || step === MetaStep.Implement) {
for (var name in definition) {
var validator = definition[name];
if ($isFunction(validator)) {
validatejs.validators[name] = validator;
}
}
}
},
shouldInherit: True,
isActive: True
});

/**
* @class {ValidationRegistry}
*/
var ValidationRegistry = Abstract.extend($registerValidators);

/**
* @class {ValidateJsCallbackHandler}
*/
Expand Down
42 changes: 33 additions & 9 deletions dist/miruken-ng-bundle.js
Expand Up @@ -22,7 +22,7 @@ new function () { // closure
version: miruken.version,
parent: miruken,
imports: "miruken,miruken.callback,miruken.context,miruken.ioc,miruken.mvc",
exports: "$rootContext,Runner,Directive"
exports: "Runner,Directive,$rootContext"
});

eval(this.imports);
Expand Down Expand Up @@ -56,13 +56,15 @@ new function () { // closure
var parent = this.parent,
module = this.ngModule;
if (module instanceof Array) {
var name = String2.slice(this, 7, -1); // [base2.xyz]
var name = String2.slice(this, 7, -1); // [base2.xyz]
module = angular.module(name, module);
module.constant('$rootContext', $rootContext);
} else if (parent) {
module = parent.ngModule;
}
Object.defineProperty(this, 'ngModule', { value: module });
if (module) {
Object.defineProperty(this, 'ngModule', { value: module });
}
if (parent === base2) {
global[this.name] = this;
}
Expand Down Expand Up @@ -5081,7 +5083,7 @@ new function () { // closure
});

var extend = Base.extend;
Base.extend = function () {
Base.extend = Abstract.extend = function () {
return (function (base, args) {
var protocols, mixins, macros,
constraints = args;
Expand Down Expand Up @@ -5152,7 +5154,7 @@ new function () { // closure
};

var implement = Base.implement;
Base.implement = function (source) {
Base.implement = Abstract.implement = function (source) {
if ($isFunction(source)) {
source = source.prototype;
}
Expand Down Expand Up @@ -6636,7 +6638,8 @@ new function () { // closure
/**
* @class {Validation}
*/
var Validation = Base.extend({
var Validation = Base.extend(
$inferProperties, {
constructor: function (object, async, scope, results) {
var _asyncResults;
async = !!async;
Expand All @@ -6661,7 +6664,8 @@ new function () { // closure
/**
* @class {ValidationResult}
*/
var ValidationResult = Base.extend($inferProperties, {
var ValidationResult = Base.extend(
$inferProperties, {
constructor: function () {
var _errors, _summary;
this.extend({
Expand Down Expand Up @@ -6829,8 +6833,8 @@ new function () { // closure
name: "validate",
version: miruken.version,
parent: miruken,
imports: "miruken.callback,miruken.validate",
exports: "ValidateJsCallbackHandler,$required,$nested"
imports: "miruken,miruken.callback,miruken.validate",
exports: "ValidationRegistry,ValidateJsCallbackHandler,$required,$nested"
});

eval(this.imports);
Expand All @@ -6844,6 +6848,26 @@ new function () { // closure

validatejs.validators.nested = Undefined;

var $registerValidators = MetaMacro.extend({
apply: function (step, metadata, target, definition) {
if (step === MetaStep.Subclass || step === MetaStep.Implement) {
for (var name in definition) {
var validator = definition[name];
if ($isFunction(validator)) {
validatejs.validators[name] = validator;
}
}
}
},
shouldInherit: True,
isActive: True
});

/**
* @class {ValidationRegistry}
*/
var ValidationRegistry = Abstract.extend($registerValidators);

/**
* @class {ValidateJsCallbackHandler}
*/
Expand Down

0 comments on commit bd208bf

Please sign in to comment.