1+ import type { SimpleObject } from '../types'
12import { cloneDeep , get , has , omit } from 'lodash'
23import { is , toCamelCase , toSnakeCase } from '../util'
34
45class Validator {
56 public successful : boolean
67 public processing : boolean
78
8- constructor ( public errors : Record < string , any > = { } ) {
9+ constructor ( public errors : SimpleObject < any > = { } ) {
910 this . processing = false
1011 this . successful = false
1112 }
@@ -24,7 +25,7 @@ class Validator {
2425 return is ( Object . keys ( this . errors ) , fields )
2526 }
2627
27- first ( field : string | string [ ] ) : string | Record < string , any > | undefined {
28+ first ( field : string | string [ ] ) : string | undefined {
2829 if ( Array . isArray ( field ) ) {
2930 const fields = this . fields ( field )
3031 let fd = ''
@@ -42,7 +43,7 @@ class Validator {
4243 }
4344 }
4445
45- firstBy ( obj : Record < string , any > , field ?: string ) {
46+ firstBy ( obj : SimpleObject < any > , field ?: string ) {
4647 let value : string
4748 if ( ! field ) {
4849 value = obj [ Object . keys ( obj ) [ 0 ] ]
@@ -64,7 +65,7 @@ class Validator {
6465 any ( field : string [ ] = [ ] , returnObject ?: boolean ) {
6566 const fields = this . fields ( field )
6667 if ( returnObject ) {
67- const errors : Record < string , any > = { }
68+ const errors : SimpleObject < any > = { }
6869 if ( ! fields . length ) return { }
6970 for ( const f of fields ) {
7071 const val = this . get ( f )
@@ -74,7 +75,7 @@ class Validator {
7475 return errors
7576 }
7677 if ( ! fields . length ) return Object . keys ( this . errors ) . length > 0
77- const errors : Record < string , any > = { }
78+ const errors : SimpleObject < any > = { }
7879 fields . forEach ( ( key : string ) => ( errors [ key ] = this . get ( key ) ) )
7980 return Object . keys ( errors ) . length > 0
8081 }
@@ -91,7 +92,7 @@ class Validator {
9192 return Object . keys ( this . errors ) . length
9293 }
9394
94- fill ( errors : Record < string , any > ) {
95+ fill ( errors : SimpleObject < any > ) {
9596 this . errors = errors
9697 }
9798
0 commit comments