From da1982687c7dfeaf5ec992d0e761037e0f9996c7 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 2 Jan 2014 15:49:20 +0000 Subject: [PATCH] jQuery.validation: Gave definition to errorMap --- jquery.validation/jquery.validation-tests.ts | 4 ++-- jquery.validation/jquery.validation.d.ts | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/jquery.validation/jquery.validation-tests.ts b/jquery.validation/jquery.validation-tests.ts index cfb10489b..64fe6ef94 100644 --- a/jquery.validation/jquery.validation-tests.ts +++ b/jquery.validation/jquery.validation-tests.ts @@ -111,7 +111,7 @@ function test_validate() { submitHandler: function () { alert("Submitted!") } }); $(".selector").validate({ - showErrors: function (errorMap, errorList) { + showErrors: function (errorMap: ErrorDictionary, errorList: ErrorListItem[]) { $("#summary").html("Your form contains " + this.numberOfInvalids() + " errors, see details below."); this.defaultShowErrors(); } @@ -193,7 +193,7 @@ function test_methods() { validator.hideErrors(); var isValid: boolean = validator.valid(); var size: number = validator.size(); - var errorMap: Object = validator.errorMap; + var errorMap: ErrorDictionary = validator.errorMap; var errorList: ErrorListItem[] = validator.errorList; $("#summary").text(validator.numberOfInvalids() + " field(s) are invalid"); diff --git a/jquery.validation/jquery.validation.d.ts b/jquery.validation/jquery.validation.d.ts index afdbcea5d..301bf6bc6 100644 --- a/jquery.validation/jquery.validation.d.ts +++ b/jquery.validation/jquery.validation.d.ts @@ -28,7 +28,7 @@ interface ValidationOptions onkeyup?: boolean; onsubmit?: boolean; rules?: Object; - showErrors?: (errorMap: Object, errorList: ErrorListItem[]) => void; + showErrors?: (errorMap: ErrorDictionary, errorList: ErrorListItem[]) => void; submitHandler?: (form: HTMLFormElement) => void; success?: any; unhighlight?: (element: HTMLElement, errorClass: string, validClass: string) => void; @@ -36,6 +36,11 @@ interface ValidationOptions wrapper?: string; } +interface ErrorDictionary +{ + [name: string]: string; +} + interface ErrorListItem { message: string; @@ -59,7 +64,7 @@ interface Validator valid(): boolean; size(): number; - errorMap: Object; + errorMap: ErrorDictionary; errorList: ErrorListItem[]; }