diff --git a/types/vuelidate/index.d.ts b/types/vuelidate/index.d.ts index cc8169cbda..05cdf26e31 100644 --- a/types/vuelidate/index.d.ts +++ b/types/vuelidate/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/monterail/vuelidate // Definitions by: Jan Esser // Jubair Saidi +// Orblazer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 diff --git a/types/vuelidate/lib/validators.d.ts b/types/vuelidate/lib/validators.d.ts index fcc13adaa9..f335c4da3b 100644 --- a/types/vuelidate/lib/validators.d.ts +++ b/types/vuelidate/lib/validators.d.ts @@ -18,7 +18,7 @@ export interface ValidationRule { $pending(): boolean } -export type CustomRule = (value: any, parentVm?: any) => boolean +export type CustomRule = (value: any, parentVm?: any) => boolean | Promise export interface Helpers { withParams(params: Params, rule: CustomRule | ValidationRule): ValidationRule diff --git a/types/vuelidate/vuelidate-tests.ts b/types/vuelidate/vuelidate-tests.ts index 0376c01cc1..d69d772405 100644 --- a/types/vuelidate/vuelidate-tests.ts +++ b/types/vuelidate/vuelidate-tests.ts @@ -1,5 +1,5 @@ import { Validation } from 'vuelidate' -import { required, integer, decimal, minLength, sameAs, helpers } from 'vuelidate/lib/validators' +import { required, integer, decimal, minLength, sameAs, helpers, CustomRule } from 'vuelidate/lib/validators' import Vue, { ComponentOptions } from 'vue' @@ -10,11 +10,11 @@ function Component(options: ComponentOptions | VueClass): any { return null; // mocked } -const mustBeCool = (value: string) => value.indexOf('cool') >= 0 +const mustBeCool: CustomRule = (value: string) => value.indexOf('cool') >= 0 -const mustBeCool2 = (value: string) => !helpers.req(value) || value.indexOf('cool') >= 0 +const mustBeCool2: CustomRule = (value: string) => !helpers.req(value) || value.indexOf('cool') >= 0 -const contains = (param: string) => +const contains = (param: string): CustomRule => (value: string) => !helpers.req(value) || value.indexOf(param) >= 0 const mustBeCool3 = helpers.withParams( diff --git a/types/vuelidate/vuelidate.d.ts b/types/vuelidate/vuelidate.d.ts index 4755049fe9..9b4f21d7f5 100644 --- a/types/vuelidate/vuelidate.d.ts +++ b/types/vuelidate/vuelidate.d.ts @@ -10,13 +10,15 @@ export const validationMixin: any // const Validation export interface Validation extends Vue { + $model: any // const validationGetters readonly $invalid: boolean readonly $dirty: boolean + readonly $anyDirty: boolean readonly $error: boolean + readonly $anyError: boolean readonly $pending: boolean readonly $params: { [attr: string]: any } - $model: any // const validationMethods $touch(): never