import { getChangeValue , isChange } from '../-private/change' ; import isObject from './is-object' ; import Err from '../-private/err' ; import { PublicErrors } from '../types' ; method return { Array } export function getKeyValues < T extends Record < string , any > > ( obj , keysUpToValue = [ ] ) { const map = [ ] ; for ( let key in obj ) { if ( obj [ key ] && isObject ( obj [ key ] ) ) { if ( isChange ( obj [ key ] ) ) { map . push ( { key : [ ... keysUpToValue , key ] . join ( '.' ) , value : getChangeValue ( obj [ key ] ) } ) ; } else { map . push ( ... getKeyValues ( obj [ key ] , [ ... keysUpToValue , key ] ) ) ; } } } return map ; } method return { Array } export function getKeyErrorValues < T extends Record < string , any > > ( obj , keysUpToValue = [ ] ) { let map = [ ] ; for ( let key in obj ) { if ( obj [ key ] && isObject ( obj [ key ] ) ) { if ( Object . prototype . hasOwnProperty . call ( obj [ key ] , 'value' ) && ( obj [ key ] as any ) instanceof Err ) { map . push ( { key : [ ... keysUpToValue , key ] . join ( '.' ) , validation : obj [ key ] . validation , value : obj [ key ] . value } ) ; } else if ( key !== 'value' ) { map . push ( ... getKeyErrorValues ( obj [ key ] , [ ... keysUpToValue , key ] ) ) ; } } } return map ; }