Skip to content

Commit ce1031e

Browse files
committed
fix: 🐛 remove the return type annotataion
1 parent b1c16d2 commit ce1031e

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/core/Validator.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ class Validator {
5050
}
5151
const value = this.get(field as string)
5252
if (Array.isArray(value)) return value[0]
53-
return value // return it if object like
53+
return value
5454
}
5555

56-
firstBy(obj: Record<string, any>, field?: string): string {
57-
let value
56+
firstBy(obj: Record<string, any>, field?: string) {
57+
let value: string
5858
if (!field) {
5959
value = obj[Object.keys(obj)[0]]
6060
} else {
@@ -64,15 +64,15 @@ class Validator {
6464
return value
6565
}
6666

67-
missed(field: string | string[]): boolean {
67+
missed(field: string | string[]) {
6868
return !this.has(field)
6969
}
7070

71-
nullState(field: string | string[]): boolean | null {
71+
nullState(field: string | string[]) {
7272
return this.has(field) ? this.missed(field) : null
7373
}
7474

75-
any(fields: string[] = [], returnObject?: boolean): boolean | string[] | any {
75+
any(fields: string[] = [], returnObject?: boolean) {
7676
if (returnObject) {
7777
const errors: Record<string, any> = {}
7878
if (!fields.length) {
@@ -90,7 +90,7 @@ class Validator {
9090
}
9191

9292
get(field: string): string | string[] {
93-
return get(this.errors, field) || []
93+
return get(this.errors, field, [])
9494
}
9595

9696
all() {
@@ -106,13 +106,11 @@ class Validator {
106106
}
107107

108108
flush() {
109-
this.errors = {}
109+
this.fill({})
110110
}
111111

112112
clear(attribute?: string | string[]) {
113-
if (!attribute) {
114-
return this.flush()
115-
}
113+
if (!attribute) return this.flush()
116114
const errors = omit(cloneDeep(this.errors), attribute)
117115
this.fill(errors)
118116
}

0 commit comments

Comments
 (0)