@@ -39,41 +39,40 @@ export abstract class AbstractGuardExtensionFactory {
3939
4040 const errors : Array < GuardError > = [ ]
4141
42- if ( methodMap ) {
43- const paramIndexes : Map < number , AbstractGuardExtensionFactoryOptions > | undefined =
44- methodMap . get ( methodName )
45-
46- if ( paramIndexes ) {
47- for ( const [ index , paramValue ] of paramValues . entries ( ) ) {
48- if ( paramIndexes . has ( index ) ) {
49- const options = paramIndexes . get ( index )
50-
51- if (
52- ! ( options ! . options ?. optional && ( paramValue === undefined || paramValue === null ) )
53- ) {
54- const values : Array < any > = options ! . options ?. each ? paramValue : [ paramValue ]
55-
56- if ( ! Array . isArray ( values ) ) {
57- errors . push (
58- new GuardError ( 'guard.against.not-array' , String ( index ) , paramValue , 'not array' )
59- )
60- } else {
61- values . forEach ( ( value ) => {
62- try {
63- this . performParamValue ( value , options ! )
64- } catch ( error ) {
65- if ( error instanceof GuardError ) {
66- errors . push ( error )
67- } else {
68- throw error
69- }
70- }
71- } )
72- }
73- }
42+ if ( ! methodMap ) return errors
43+
44+ const paramIndexes : Map < number , AbstractGuardExtensionFactoryOptions > | undefined =
45+ methodMap . get ( methodName )
46+
47+ if ( ! paramIndexes ) return errors
48+
49+ for ( const [ index , paramValue ] of paramValues . entries ( ) ) {
50+ if ( ! paramIndexes . has ( index ) ) continue
51+ const options = paramIndexes . get ( index )
52+
53+ if ( options ! . options ?. optional && ( paramValue === undefined || paramValue === null ) ) {
54+ continue
55+ }
56+
57+ const values : Array < any > = options ! . options ?. each ? paramValue : [ paramValue ]
58+
59+ if ( ! Array . isArray ( values ) ) {
60+ errors . push (
61+ new GuardError ( 'guard.against.not-array' , String ( index ) , paramValue , 'not array' )
62+ )
63+ continue
64+ }
65+
66+ values . forEach ( ( value ) => {
67+ try {
68+ this . performParamValue ( value , options ! )
69+ } catch ( error ) {
70+ if ( ! ( error instanceof GuardError ) ) {
71+ throw error
7472 }
73+ errors . push ( error )
7574 }
76- }
75+ } )
7776 }
7877
7978 return errors
0 commit comments