[@types/vuelidate] Add return for async rule (#36159)

* Add return for async rule

* Add missing validation properties

* Remove useless property

* Strict type of custom rules
This commit is contained in:
orblazer
2019-08-19 12:00:38 -07:00
committed by Sheetal Nandi
parent 26c41b10db
commit 65355267e7
4 changed files with 9 additions and 6 deletions
+1
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/monterail/vuelidate
// Definitions by: Jan Esser <https://github.com/janesser>
// Jubair Saidi <https://github.com/jubairsaidi>
// Orblazer <https://github.com/orblazer>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
+1 -1
View File
@@ -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<boolean>
export interface Helpers {
withParams(params: Params, rule: CustomRule | ValidationRule): ValidationRule
+4 -4
View File
@@ -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<Vue> | VueClass<Vue>): 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(
+3 -1
View File
@@ -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