File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
shared/hook-form/validation Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 11import type { DepositData , DepositDataSDK } from '@lidofinance/lido-csm-sdk' ;
2- import { groupBy , mapValues } from 'lodash' ;
2+ import { groupBy , mapValues , uniqBy } from 'lodash' ;
33import { KEYS_UPLOAD_TX_LIMIT } from 'consts/keys' ;
44import { ValidationError } from './validation-error' ;
55
@@ -22,9 +22,14 @@ export const validateDepositData = async ({
2222 const errors = await sdk . validateDepositData ( depositData ) ;
2323
2424 if ( errors ?. length ) {
25- const types = mapValues ( groupBy ( errors , 'index' ) , ( errors ) =>
26- errors . map ( ( error ) => error . message ) ,
27- ) ;
25+ const types = mapValues ( groupBy ( errors , 'index' ) , ( errors ) => {
26+ const withField = errors . filter ( ( e ) => e . field ) ;
27+ const withoutField = errors . filter ( ( e ) => ! e . field ) ;
28+ const uniqueWithField = uniqBy ( withField , 'field' ) ;
29+ return [ ...uniqueWithField , ...withoutField ] . map (
30+ ( error ) => error . message ,
31+ ) ;
32+ } ) ;
2833
2934 throw new ValidationError (
3035 'depositData' ,
You can’t perform that action at this time.
0 commit comments