mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
Merge pull request #30832 from jubairsaidi/master
Update validators.d.ts
This commit is contained in:
Vendored
+1
@@ -1,6 +1,7 @@
|
||||
// Type definitions for vuelidate 0.7
|
||||
// Project: https://github.com/janesser/vuelidate.ts
|
||||
// Definitions by: Jan Esser <https://github.com/janesser>
|
||||
// Jubair Saidi <https://github.com/jubairsaidi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
|
||||
Vendored
+7
-4
@@ -18,10 +18,10 @@ export interface ValidationRule {
|
||||
$pending(): boolean
|
||||
}
|
||||
|
||||
export type CustomRule = (value: any, parentVm?: Vue) => boolean
|
||||
export type CustomRule = (value: any, parentVm?: any) => boolean
|
||||
|
||||
export interface Helpers {
|
||||
withParams(params: Params, rule: CustomRule): ValidationRule
|
||||
withParams(params: Params, rule: CustomRule | ValidationRule): ValidationRule
|
||||
req(value: any): ValidationRule
|
||||
ref(reference: string | ((vm: any, parentVm?: Vue) => any), vm: any, parentVm?: Vue): any
|
||||
len(value: any): number
|
||||
@@ -42,10 +42,13 @@ export function between(min: number, max: number): ValidationRule
|
||||
export function alpha(): ValidationRule
|
||||
export function alphaNum(): ValidationRule
|
||||
export function numeric(): ValidationRule
|
||||
export function integer(): ValidationRule
|
||||
export function decimal(): ValidationRule
|
||||
export function email(): ValidationRule
|
||||
export function ipAddress(): ValidationRule
|
||||
export function macAddress(): ValidationRule
|
||||
export function sameAs(field: string | ((vm: any, parentVm?: Vue) => any)): ValidationRule
|
||||
export function url(): ValidationRule
|
||||
export function or(...validators: ValidationRule[]): ValidationRule
|
||||
export function and(...validators: ValidationRule[]): ValidationRule
|
||||
export function not(validator: ValidationRule | CustomRule): ValidationRule
|
||||
export function or(...validators: Array<ValidationRule | CustomRule>): ValidationRule
|
||||
export function and(...validators: Array<ValidationRule | CustomRule>): ValidationRule
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Validation } from 'vuelidate'
|
||||
import { required, minLength, sameAs, helpers } from 'vuelidate/lib/validators'
|
||||
import { required, integer, decimal, minLength, sameAs, helpers } from 'vuelidate/lib/validators'
|
||||
|
||||
import Vue, { ComponentOptions } from 'vue'
|
||||
|
||||
@@ -54,14 +54,25 @@ const mustHaveLength = (minLen: number) => helpers.withParams(
|
||||
},
|
||||
nestedB: {
|
||||
required
|
||||
},
|
||||
nestedOfLength: {
|
||||
mustHaveLength: mustHaveLength(6)
|
||||
}
|
||||
},
|
||||
age: {
|
||||
required,
|
||||
integer
|
||||
},
|
||||
coolFactor: {
|
||||
required,
|
||||
decimal
|
||||
},
|
||||
flatA: { required },
|
||||
flatB: { required },
|
||||
forGroup: {
|
||||
nested: { required }
|
||||
},
|
||||
validationGroup: ['flatA', 'flatB', 'forGroup.nested'],
|
||||
validationGroup: ['age', 'coolFactor', 'flatA', 'flatB', 'forGroup.nested'],
|
||||
people: {
|
||||
required,
|
||||
minLength: minLength(3),
|
||||
@@ -90,7 +101,7 @@ const mustHaveLength = (minLen: number) => helpers.withParams(
|
||||
required,
|
||||
mustBeCool,
|
||||
mustBeCool2,
|
||||
containsA: contains("a"),
|
||||
containsA: contains('a'),
|
||||
mustBeCool3
|
||||
}
|
||||
}
|
||||
@@ -101,9 +112,13 @@ export class ValidComponent extends Vue {
|
||||
|
||||
form = {
|
||||
nestedA: 'A',
|
||||
nestedB: 'B'
|
||||
nestedB: 'B',
|
||||
nestedOfLength: ''
|
||||
}
|
||||
|
||||
age = 50
|
||||
coolFactor = 0.25
|
||||
|
||||
flatA = ''
|
||||
flatB = ''
|
||||
forGroup = {
|
||||
@@ -132,6 +147,8 @@ export class ValidComponent extends Vue {
|
||||
console.log(this.$v.form.$params)
|
||||
console.log(this.$v.form.$params.nestedA)
|
||||
console.log(this.$v.form.nestedA)
|
||||
console.log(this.$v.form.$params.nestedOfLength)
|
||||
console.log(this.$v.form.nestedOfLength)
|
||||
}
|
||||
console.log(this.$v.validationGroup.$params)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user