-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6a0edc
commit 2d310c1
Showing
80 changed files
with
1,647 additions
and
1,282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
declare module 'aurelia-validatejs' { | ||
import { | ||
DOM | ||
} from 'aurelia-pal'; | ||
import { | ||
ValidationError | ||
} from 'aurelia-validation'; | ||
import { | ||
inject | ||
} from 'aurelia-dependency-injection'; | ||
import { | ||
metadata | ||
} from 'aurelia-metadata'; | ||
import validate from 'validate.js'; | ||
export class ValidationRenderer { | ||
renderErrors(node: any, relevantErrors: any): any; | ||
unrenderErrors(node: any): any; | ||
} | ||
export class ValidationConfig { | ||
__validationRules__: any; | ||
addRule(key: any, rule: any): any; | ||
validate(instance: any, reporter: any, key: any): any; | ||
getValidationRules(): any; | ||
aggregateValidationRules(): any; | ||
} | ||
|
||
//get __validationRules__ from class using metadata | ||
//merge with any instance specific __validationRules__ | ||
export const validationMetadataKey: any; | ||
export class ValidationObserver { | ||
id: any; | ||
callback: any; | ||
reporter: any; | ||
constructor(reporter: any, callback: any); | ||
dispose(): any; | ||
} | ||
export class ValidationReporter { | ||
callback: any; | ||
__callbacks__: any; | ||
subscribe(callback: any): any; | ||
publish(errors: any): any; | ||
destroyObserver(observer: any): any; | ||
} | ||
export class ValidationRule { | ||
name: any; | ||
config: any; | ||
constructor(name: any, config: any); | ||
validate(target: any, propName: any): any; | ||
static date(config?: any): any; | ||
static datetime(config?: any): any; | ||
static email(config?: any): any; | ||
static equality(config: any): any; | ||
static exclusion(config: any): any; | ||
static format(config: any): any; | ||
static inclusion(config: any): any; | ||
static lengthRule(config: any): any; | ||
static numericality(config?: any): any; | ||
static presence(config?: any): any; | ||
static url(config?: any): any; | ||
} | ||
export function cleanResult(data: any): any; | ||
export class ValidateBindingBehavior { | ||
constructor(renderer: any); | ||
bind(binding: any, source: any): any; | ||
unbind(binding: any, source: any): any; | ||
|
||
// let targetProperty = this.getTargetProperty(source); | ||
// let target = this.getPropertyContext(source, targetProperty); | ||
// let reporter = this.getReporter(source); | ||
getTargetProperty(binding: any): any; | ||
getPropertyContext(source: any, targetProperty: any): any; | ||
getReporter(source: any): any; | ||
} | ||
export class ValidationEngine { | ||
static getValidationReporter(instance: any): any; | ||
} | ||
export function observeProperty(target: any, key: any, descriptor: any, targetOrConfig: any, rule: any): any; | ||
export class Validator { | ||
object: any; | ||
config: any; | ||
constructor(object: any); | ||
validate(prop: any): any; | ||
getProperties(): any; | ||
ensure(prop: any): any; | ||
length(configuration: any): any; | ||
presence(): any; | ||
required(): any; | ||
numericality(): any; | ||
date(): any; | ||
datetime(): any; | ||
email(): any; | ||
equality(configuration: any): any; | ||
format(configuration: any): any; | ||
inclusion(configuration: any): any; | ||
exclusion(configuration: any): any; | ||
url(): any; | ||
} | ||
export function base(targetOrConfig: any, key: any, descriptor: any, rule: any): any; | ||
export function length(targetOrConfig: any, key: any, descriptor: any): any; | ||
export function presence(targetOrConfig: any, key: any, descriptor: any): any; | ||
export function required(targetOrConfig: any, key: any, descriptor: any): any; | ||
export function date(targetOrConfig: any, key: any, descriptor: any): any; | ||
export function datetime(targetOrConfig: any, key: any, descriptor: any): any; | ||
export function email(targetOrConfig: any, key: any, descriptor: any): any; | ||
export function equality(targetOrConfig: any, key: any, descriptor: any): any; | ||
export function exclusion(targetOrConfig: any, key: any, descriptor: any): any; | ||
export function inclusion(targetOrConfig: any, key: any, descriptor: any): any; | ||
export function format(targetOrConfig: any, key: any, descriptor: any): any; | ||
export function url(targetOrConfig: any, key: any, descriptor: any): any; | ||
export function numericality(targetOrConfig: any, key: any, descriptor: any): any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,18 @@ | ||
define(['exports', 'aurelia-metadata', './validation-config', './validation-engine', 'aurelia-validation'], function (exports, _aureliaMetadata, _validationConfig, _validationEngine, _aureliaValidation) { | ||
define(['exports', './property-observer'], function (exports, _propertyObserver) { | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.base = base; | ||
function base(targetOrConfig, key, descriptor, Rule) { | ||
var deco = function deco(target, key2, descriptor2) { | ||
var config = _aureliaMetadata.metadata.getOrCreateOwn(_aureliaValidation.validationMetadataKey, _validationConfig.ValidationConfig, target); | ||
config.addRule(key2, new Rule(targetOrConfig)); | ||
|
||
var innerPropertyName = '_' + key2; | ||
|
||
if (descriptor2.initializer) { | ||
target[innerPropertyName] = descriptor2.initializer(); | ||
} | ||
|
||
delete descriptor2.writable; | ||
delete descriptor2.initializer; | ||
|
||
descriptor2.get = function () { | ||
return this[innerPropertyName]; | ||
}; | ||
descriptor2.set = function (newValue) { | ||
var reporter = _validationEngine.ValidationEngine.getValidationReporter(this); | ||
|
||
this[innerPropertyName] = newValue; | ||
|
||
config.validate(this, reporter); | ||
}; | ||
|
||
descriptor2.get.dependencies = [innerPropertyName]; | ||
}; | ||
|
||
function base(targetOrConfig, key, descriptor, rule) { | ||
if (key) { | ||
var target = targetOrConfig; | ||
targetOrConfig = null; | ||
return deco(target, key, descriptor); | ||
return (0, _propertyObserver.observeProperty)(target, key, descriptor, targetOrConfig, rule); | ||
} | ||
return deco; | ||
return function (t, k, d) { | ||
return (0, _propertyObserver.observeProperty)(t, k, d, targetOrConfig, rule); | ||
}; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
define(['exports', 'aurelia-metadata', './validation-config', './validation-engine', './metadata-key'], function (exports, _aureliaMetadata, _validationConfig, _validationEngine, _metadataKey) { | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.observeProperty = observeProperty; | ||
function observeProperty(target, key, descriptor, targetOrConfig, rule) { | ||
var config = _aureliaMetadata.metadata.getOrCreateOwn(_metadataKey.validationMetadataKey, _validationConfig.ValidationConfig, target); | ||
config.addRule(key, rule(targetOrConfig)); | ||
|
||
var innerPropertyName = '_' + key; | ||
|
||
var babel = descriptor !== undefined; | ||
|
||
if (babel) { | ||
if (typeof descriptor.initializer === 'function') { | ||
target[innerPropertyName] = descriptor.initializer(); | ||
} | ||
} else { | ||
descriptor = {}; | ||
} | ||
|
||
delete descriptor.writable; | ||
delete descriptor.initializer; | ||
|
||
descriptor.get = function () { | ||
return this[innerPropertyName]; | ||
}; | ||
descriptor.set = function (newValue) { | ||
var reporter = _validationEngine.ValidationEngine.getValidationReporter(this); | ||
|
||
this[innerPropertyName] = newValue; | ||
|
||
config.validate(this, reporter); | ||
}; | ||
|
||
descriptor.get.dependencies = [innerPropertyName]; | ||
|
||
if (!babel) { | ||
Reflect.defineProperty(target, key, descriptor); | ||
} | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.