From 19d40360f893ec8f3804a07711fa0eea51b17e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Olivera?= Date: Sun, 6 Jan 2019 16:49:16 -0300 Subject: [PATCH] Code formatting with Prettier --- types/validatorjs/index.d.ts | 78 +++++++++++++------------- types/validatorjs/validatorjs-tests.ts | 59 ++++++++++--------- 2 files changed, 68 insertions(+), 69 deletions(-) diff --git a/types/validatorjs/index.d.ts b/types/validatorjs/index.d.ts index 9a660c5966..1a41866d0f 100644 --- a/types/validatorjs/index.d.ts +++ b/types/validatorjs/index.d.ts @@ -6,64 +6,64 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace Validator { - interface ValidationErrors { - [field: string]: string + [field: string]: string; } interface ErrorMessages { - [key: string]: string | ErrorMessages + [key: string]: string | ErrorMessages; } interface AttributeNames { - [attribute: string]: string + [attribute: string]: string; } - type AttributeFormatter = (attribute: any) => any + type AttributeFormatter = (attribute: any) => any; interface Errors { - errors : ValidationErrors - add (attribute: string, message: string): void - get (attribute: string): Array - first (attribute: string): string | boolean - all (): ValidationErrors - has (attribute: string): boolean + errors: ValidationErrors; + add(attribute: string, message: string): void; + get(attribute: string): Array; + first(attribute: string): string | boolean; + all(): ValidationErrors; + has(attribute: string): boolean; } interface ValidatorStatic { - new (data: A, rules: any, customMessages?: ErrorMessages): Validator - setMessages (lang: string, messages: ErrorMessages): any - getMessages (lang: string): ErrorMessages - useLang (lang: string): void - getDefaultLang (): string - setAttributeFormatter (func: AttributeFormatter): void - stopOnError (attributes: boolean | Array): void - register (name: string, fn: Function, message: string): void - registerAsync (name: string, fn: Function, message: string): void + new (data: A, rules: any, customMessages?: ErrorMessages): Validator< + A + >; + setMessages(lang: string, messages: ErrorMessages): any; + getMessages(lang: string): ErrorMessages; + useLang(lang: string): void; + getDefaultLang(): string; + setAttributeFormatter(func: AttributeFormatter): void; + stopOnError(attributes: boolean | Array): void; + register(name: string, fn: Function, message: string): void; + registerAsync(name: string, fn: Function, message: string): void; } interface Validator { - lang: string - input: A - messages: ErrorMessages - errors: Errors - errorCount: number - hasAsync: boolean - rules: any - numericRules: Array - attributeFormatter: AttributeFormatter - check (): boolean - checkAsync (passes?: Function, fails?: Function): void - setAttributeNames (attributes: AttributeNames): void - setAttributeFormatter (func: AttributeFormatter): void - getRule (name: string): Function - stopOnError (passes?: Function): boolean | void - passes (passes?: Function): boolean | void - fails (fails?: Function): boolean | void + lang: string; + input: A; + messages: ErrorMessages; + errors: Errors; + errorCount: number; + hasAsync: boolean; + rules: any; + numericRules: Array; + attributeFormatter: AttributeFormatter; + check(): boolean; + checkAsync(passes?: Function, fails?: Function): void; + setAttributeNames(attributes: AttributeNames): void; + setAttributeFormatter(func: AttributeFormatter): void; + getRule(name: string): Function; + stopOnError(passes?: Function): boolean | void; + passes(passes?: Function): boolean | void; + fails(fails?: Function): boolean | void; } - } -declare const Validator: Validator.ValidatorStatic +declare const Validator: Validator.ValidatorStatic; export = Validator; export as namespace Validator; diff --git a/types/validatorjs/validatorjs-tests.ts b/types/validatorjs/validatorjs-tests.ts index 4eb24ed6bd..4ab3e28159 100644 --- a/types/validatorjs/validatorjs-tests.ts +++ b/types/validatorjs/validatorjs-tests.ts @@ -1,41 +1,40 @@ -import Validator = require("validatorjs"); +import Validator = require('validatorjs'); var rules: any = { - foo: "required" -} + foo: 'required' +}; var data: any = { - foo: "bar" -} + foo: 'bar' +}; -var validator: Validator.Validator = new Validator(data, rules) +var validator: Validator.Validator = new Validator(data, rules); -var passes: boolean = validator.passes() as boolean -validator.passes(() => {}) +var passes: boolean = validator.passes() as boolean; +validator.passes(() => {}); -var fails: boolean = validator.fails() as boolean -validator.fails(() => {}) +var fails: boolean = validator.fails() as boolean; +validator.fails(() => {}); -var check: boolean = validator.check() +var check: boolean = validator.check(); -var errors: Validator.Errors = validator.errors -var all: Validator.ValidationErrors = errors.all() -var error: Array = errors.get("foo") -var first: string | boolean = errors.first("foo") -var has: boolean = errors.has("foo") +var errors: Validator.Errors = validator.errors; +var all: Validator.ValidationErrors = errors.all(); +var error: Array = errors.get('foo'); +var first: string | boolean = errors.first('foo'); +var has: boolean = errors.has('foo'); -Validator.setMessages("en", { - integer: 'The :attribute must be an integer.', - min: { - numeric: 'The :attribute must be at least :min.', - string: 'The :attribute must be at least :min characters.' - } +Validator.setMessages('en', { + integer: 'The :attribute must be an integer.', + min: { + numeric: 'The :attribute must be at least :min.', + string: 'The :attribute must be at least :min characters.' } -); -var messages: Validator.ErrorMessages = Validator.getMessages("en") -Validator.useLang("en") -var lang: string = Validator.getDefaultLang() -Validator.setAttributeFormatter((attributes: any) => ({})) -Validator.stopOnError(true) -Validator.register("custom", () => {}, "error.custom") -Validator.registerAsync("custom", () => {}, "error.custom") +}); +var messages: Validator.ErrorMessages = Validator.getMessages('en'); +Validator.useLang('en'); +var lang: string = Validator.getDefaultLang(); +Validator.setAttributeFormatter((attributes: any) => ({})); +Validator.stopOnError(true); +Validator.register('custom', () => {}, 'error.custom'); +Validator.registerAsync('custom', () => {}, 'error.custom');