mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
[@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:
Vendored
+1
@@ -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
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
Vendored
+3
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user