mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
// vue augmentation
|
|
import Vue, { ComponentOptions } from 'vue'
|
|
|
|
import { ValidationRule } from './lib/validators'
|
|
import { Validation } from './vuelidate'
|
|
|
|
declare module 'vue/types/vue' {
|
|
type ValidationProperties<V> = {
|
|
[P in keyof V]?: Validation & ValidationProperties<V[P]> & ValidationEvaluation
|
|
}
|
|
|
|
interface ValidationGroups {
|
|
[groupName: string]: Validation & ValidationProperties<any>
|
|
}
|
|
|
|
interface ValidationEvaluation {
|
|
[ruleName: string]: boolean
|
|
}
|
|
|
|
interface Vue {
|
|
$v: ValidationProperties<this> & ValidationGroups & Validation
|
|
|
|
delayTouch(v: Validation): void
|
|
}
|
|
}
|
|
|
|
declare module 'vue/types/options' {
|
|
interface ValidGroupDecl {
|
|
[group: string]: string[]
|
|
}
|
|
|
|
interface ValidPropertyDecl {
|
|
[prop: string]: RuleDecl
|
|
}
|
|
|
|
type ValidationDecl = ValidationRule | ((...args: any[]) => ValidationRule)
|
|
type GroupDecl = string[]
|
|
type AsyncDecl = (...args: any[]) => boolean | Promise<boolean>
|
|
type NestedDecl = RuleDecl
|
|
type DynamicDecl = () => RuleDecl
|
|
interface RuleDecl {
|
|
[rule: string]: ValidationDecl | GroupDecl | AsyncDecl | NestedDecl
|
|
}
|
|
|
|
interface ComponentOptions<V extends Vue> {
|
|
validations?: RuleDecl | DynamicDecl
|
|
}
|
|
}
|