mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Using a combination of the source code and the documentation at http://jqueryvalidation.org/validate/ I've tightened up the ValidationOptions. NB success remains as any because (AFAIK) it's not possible to model alternate overloads in an interface with TypeScript ( https://typescript.codeplex.com/workitem/1893 ).
80 lines
2.2 KiB
TypeScript
80 lines
2.2 KiB
TypeScript
// Type definitions for jquery.validation 1.11.1
|
|
// Project: http://bassistance.de/jquery-plugins/jquery-plugin-validation/
|
|
// Definitions by: https://github.com/fdecampredon
|
|
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
|
|
|
|
|
/// <reference path="../jquery/jquery.d.ts"/>
|
|
|
|
interface ValidationOptions
|
|
{
|
|
debug?: boolean;
|
|
errorClass?: string;
|
|
errorContainer?: string;
|
|
errorElement?: string;
|
|
errorLabelContainer?: string;
|
|
errorPlacement?: (error: JQuery, element: JQuery) => void;
|
|
focusCleanup?: boolean;
|
|
focusInvalid?: boolean;
|
|
groups?: Object;
|
|
highlight?: (element: HTMLElement, errorClass: string, validClass: string) => void;
|
|
ignore?: string;
|
|
ignoreTitle?: boolean;
|
|
invalidHandler?: (event: JQueryEventObject, validator: Validator) => void;
|
|
messages?: Object;
|
|
meta?: string;
|
|
onclick?: boolean;
|
|
onfocusout?: boolean;
|
|
onkeyup?: boolean;
|
|
onsubmit?: boolean;
|
|
rules?: Object;
|
|
showErrors?: (errorMap: Object, errorList: ErrorListItem[]) => void;
|
|
submitHandler?: (form: HTMLFormElement) => void;
|
|
success?: any;
|
|
unhighlight?: (element: HTMLElement, errorClass: string, validClass: string) => void;
|
|
validClass?: string;
|
|
wrapper?: string;
|
|
}
|
|
|
|
interface ErrorListItem
|
|
{
|
|
message: string;
|
|
element: HTMLElement;
|
|
}
|
|
|
|
interface Validator
|
|
{
|
|
addClassRules(name: string, rules: any): void;
|
|
addClassRules(rules: any): void;
|
|
addMethod(name: string, method: (value: any, element: any, ...params: any[]) => any, message?: any): void;
|
|
element(element: any): boolean;
|
|
form(): boolean;
|
|
format(template: string, ...arguments: string[]): string;
|
|
numberOfInvalids(): number;
|
|
resetForm(): void;
|
|
setDefaults(defaults: ValidationOptions): void;
|
|
settings: ValidationOptions;
|
|
showErrors(errors: any): void;
|
|
hideErrors(): void;
|
|
valid(): boolean;
|
|
size(): number;
|
|
|
|
errorMap: Object;
|
|
errorList: ErrorListItem[];
|
|
}
|
|
|
|
interface JQuery
|
|
{
|
|
removeAttrs(attributes: string): any;
|
|
rules(): any;
|
|
rules(methodName: string): any;
|
|
rules(methodName: string, rules: any): any;
|
|
valid(): boolean;
|
|
validate(options?: ValidationOptions): Validator;
|
|
}
|
|
|
|
interface JQueryStatic
|
|
{
|
|
format(template: string, ...arguments: string[]): string;
|
|
validator: Validator;
|
|
} |