@@ -184,8 +184,54 @@ const maskingSchema = object({
184
184
type : mixed < ApplicationConfigPropertiesKafkaMaskingTypeEnum > ( )
185
185
. oneOf ( Object . values ( ApplicationConfigPropertiesKafkaMaskingTypeEnum ) )
186
186
. required ( 'required field' ) ,
187
- fields : array ( ) . of ( object ( ) . shape ( { value : string ( ) } ) ) ,
188
- fieldsNamePattern : string ( ) ,
187
+ fields : array ( ) . of (
188
+ object ( ) . shape ( {
189
+ value : string ( ) . test (
190
+ 'fieldsOrPattern' ,
191
+ 'Either fields or fieldsNamePattern is required' ,
192
+ function ( value , { path, parent, ...ctx } ) {
193
+ const maskingItem = ctx . from ?. [ 1 ] . value ;
194
+
195
+ if ( value && value . trim ( ) !== '' ) {
196
+ return true ;
197
+ }
198
+
199
+ const otherFieldHasValue =
200
+ maskingItem . fields &&
201
+ maskingItem . fields . some (
202
+ ( field : { value : string } ) =>
203
+ field . value && field . value . trim ( ) !== ''
204
+ ) ;
205
+
206
+ if ( otherFieldHasValue ) {
207
+ return true ;
208
+ }
209
+
210
+ const hasPattern =
211
+ maskingItem . fieldsNamePattern &&
212
+ maskingItem . fieldsNamePattern . trim ( ) !== '' ;
213
+
214
+ return hasPattern ;
215
+ }
216
+ ) ,
217
+ } )
218
+ ) ,
219
+ fieldsNamePattern : string ( ) . test (
220
+ 'fieldsOrPattern' ,
221
+ 'Either fields or fieldsNamePattern is required' ,
222
+ ( value , { parent } ) => {
223
+ const hasValidFields =
224
+ parent . fields &&
225
+ parent . fields . length > 0 &&
226
+ parent . fields . some (
227
+ ( field : { value : string } ) => field . value && field . value . trim ( ) !== ''
228
+ ) ;
229
+
230
+ const hasPattern = value && value . trim ( ) !== '' ;
231
+
232
+ return hasValidFields || hasPattern ;
233
+ }
234
+ ) ,
189
235
maskingCharsReplacement : array ( ) . of ( object ( ) . shape ( { value : string ( ) } ) ) ,
190
236
replacement : string ( ) ,
191
237
topicKeysPattern : string ( ) ,
0 commit comments