mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-11-29 01:31:45 +00:00
Use ES6 syntax
This commit is contained in:
@@ -54,36 +54,37 @@ function typeCheckingRules() {
|
||||
const validation = new Validator(data, rules);
|
||||
}
|
||||
|
||||
var rules: Validator.Rules = {
|
||||
const rules: Validator.Rules = {
|
||||
foo: 'required'
|
||||
};
|
||||
|
||||
var data: any = {
|
||||
const data: any = {
|
||||
foo: 'bar'
|
||||
};
|
||||
|
||||
const validator: Validator.Validator<any> = new Validator(data, rules);
|
||||
|
||||
/**
|
||||
* Passing validation
|
||||
*/
|
||||
|
||||
var passes: boolean = validator.passes() as boolean;
|
||||
const passes: boolean = validator.passes() as boolean;
|
||||
validator.passes(() => {});
|
||||
|
||||
var fails: boolean = validator.fails() as boolean;
|
||||
const fails: boolean = validator.fails() as boolean;
|
||||
validator.fails(() => {});
|
||||
|
||||
var check: boolean = validator.check();
|
||||
const check: boolean = validator.check();
|
||||
|
||||
/**
|
||||
* Validation errors
|
||||
*/
|
||||
|
||||
var errors: Validator.Errors = validator.errors;
|
||||
var all: Validator.ValidationErrors = errors.all();
|
||||
var error: Array<string> = errors.get('foo');
|
||||
var first: string | boolean = errors.first('foo');
|
||||
var has: boolean = errors.has('foo');
|
||||
const errors: Validator.Errors = validator.errors;
|
||||
const all: Validator.ValidationErrors = errors.all();
|
||||
const error: Array<string> = errors.get('foo');
|
||||
const first: string | boolean = errors.first('foo');
|
||||
const has: boolean = errors.has('foo');
|
||||
|
||||
/**
|
||||
* Validator
|
||||
@@ -96,9 +97,9 @@ Validator.setMessages('en', {
|
||||
string: 'The :attribute must be at least :min characters.'
|
||||
}
|
||||
});
|
||||
var messages: Validator.ErrorMessages = Validator.getMessages('en');
|
||||
const messages: Validator.ErrorMessages = Validator.getMessages('en');
|
||||
Validator.useLang('en');
|
||||
var lang: string = Validator.getDefaultLang();
|
||||
const lang: string = Validator.getDefaultLang();
|
||||
Validator.setAttributeFormatter((attributes: any) => ({}));
|
||||
Validator.stopOnError(true);
|
||||
Validator.register('custom', () => {}, 'error.custom');
|
||||
|
||||
Reference in New Issue
Block a user