@@ -98,17 +98,17 @@ export class StringModule {
9898 /**
9999 * Generating a string consisting of letters in the English alphabet.
100100 *
101- * @param options Either the number of characters or an options instance. Defaults to `{ length: 1, casing: 'mixed', bannedChars : [] }`.
101+ * @param options Either the number of characters or an options instance. Defaults to `{ length: 1, casing: 'mixed', exclude : [] }`.
102102 * @param options.length The number of characters to generate. Defaults to `1`.
103103 * @param options.casing The casing of the characters. Defaults to `'mixed'`.
104- * @param options.bannedChars An array with characters to exclude . Defaults to `[]`.
104+ * @param options.exclude An array with characters which should be excluded in the generated string . Defaults to `[]`.
105105 *
106106 * @example
107107 * faker.string.alpha() // 'b'
108108 * faker.string.alpha(10) // 'fEcAaCVbaR'
109109 * faker.string.alpha({ casing: 'lower' }) // 'r'
110- * faker.string.alpha({ bannedChars : ['W'] }) // 'Z'
111- * faker.string.alpha({ length: 5, casing: 'upper', bannedChars : ['A'] }) // 'DTCIC'
110+ * faker.string.alpha({ exclude : ['W'] }) // 'Z'
111+ * faker.string.alpha({ length: 5, casing: 'upper', exclude : ['A'] }) // 'DTCIC'
112112 *
113113 * @since 8.0.0
114114 */
@@ -118,7 +118,7 @@ export class StringModule {
118118 | {
119119 length ?: number ;
120120 casing ?: Casing ;
121- bannedChars ?: readonly LiteralUnion < AlphaChar > [ ] | string ;
121+ exclude ?: readonly LiteralUnion < AlphaChar > [ ] | string ;
122122 } = { }
123123 ) : string {
124124 if ( typeof options === 'number' ) {
@@ -128,10 +128,10 @@ export class StringModule {
128128 }
129129
130130 const { length = 1 , casing = 'mixed' } = options ;
131- let { bannedChars = [ ] } = options ;
131+ let { exclude = [ ] } = options ;
132132
133- if ( typeof bannedChars === 'string' ) {
134- bannedChars = bannedChars . split ( '' ) ;
133+ if ( typeof exclude === 'string' ) {
134+ exclude = exclude . split ( '' ) ;
135135 }
136136
137137 if ( length <= 0 ) {
@@ -152,11 +152,11 @@ export class StringModule {
152152 break ;
153153 }
154154
155- charsArray = charsArray . filter ( ( elem ) => ! bannedChars . includes ( elem ) ) ;
155+ charsArray = charsArray . filter ( ( elem ) => ! exclude . includes ( elem ) ) ;
156156
157157 if ( charsArray . length === 0 ) {
158158 throw new FakerError (
159- 'Unable to generate string, because all possible characters are banned .'
159+ 'Unable to generate string, because all possible characters are excluded .'
160160 ) ;
161161 }
162162
@@ -168,17 +168,17 @@ export class StringModule {
168168 /**
169169 * Generating a string consisting of alpha characters and digits.
170170 *
171- * @param options Either the number of characters or an options instance. Defaults to `{ length: 1, casing: 'mixed', bannedChars : [] }`.
171+ * @param options Either the number of characters or an options instance. Defaults to `{ length: 1, casing: 'mixed', exclude : [] }`.
172172 * @param options.length The number of characters and digits to generate. Defaults to `1`.
173173 * @param options.casing The casing of the characters. Defaults to `'mixed'`.
174- * @param options.bannedChars An array of characters and digits which should be banned in the generated string. Defaults to `[]`.
174+ * @param options.exclude An array of characters and digits which should be excluded in the generated string. Defaults to `[]`.
175175 *
176176 * @example
177177 * faker.string.alphanumeric() // '2'
178178 * faker.string.alphanumeric(5) // '3e5V7'
179179 * faker.string.alphanumeric({ casing: 'upper' }) // 'A'
180- * faker.string.alphanumeric({ bannedChars : ['W'] }) // 'r'
181- * faker.string.alphanumeric({ length: 5, bannedChars : ["a"] }) // 'x1Z7f'
180+ * faker.string.alphanumeric({ exclude : ['W'] }) // 'r'
181+ * faker.string.alphanumeric({ length: 5, exclude : ["a"] }) // 'x1Z7f'
182182 *
183183 * @since 8.0.0
184184 */
@@ -188,7 +188,7 @@ export class StringModule {
188188 | {
189189 length ?: number ;
190190 casing ?: Casing ;
191- bannedChars ?: readonly LiteralUnion < AlphaNumericChar > [ ] | string ;
191+ exclude ?: readonly LiteralUnion < AlphaNumericChar > [ ] | string ;
192192 } = { }
193193 ) : string {
194194 if ( typeof options === 'number' ) {
@@ -203,10 +203,10 @@ export class StringModule {
203203 return '' ;
204204 }
205205
206- let { bannedChars = [ ] } = options ;
206+ let { exclude = [ ] } = options ;
207207
208- if ( typeof bannedChars === 'string' ) {
209- bannedChars = bannedChars . split ( '' ) ;
208+ if ( typeof exclude === 'string' ) {
209+ exclude = exclude . split ( '' ) ;
210210 }
211211
212212 let charsArray = [ ...DIGIT_CHARS ] ;
@@ -224,11 +224,11 @@ export class StringModule {
224224 break ;
225225 }
226226
227- charsArray = charsArray . filter ( ( elem ) => ! bannedChars . includes ( elem ) ) ;
227+ charsArray = charsArray . filter ( ( elem ) => ! exclude . includes ( elem ) ) ;
228228
229229 if ( charsArray . length === 0 ) {
230230 throw new FakerError (
231- 'Unable to generate string, because all possible characters are banned .'
231+ 'Unable to generate string, because all possible characters are excluded .'
232232 ) ;
233233 }
234234
@@ -307,17 +307,17 @@ export class StringModule {
307307 /**
308308 * Generates a given length string of digits.
309309 *
310- * @param options Either the number of characters or the options to use. Defaults to `{ length: 1, allowLeadingZeros = false, bannedDigits = [] }`.
310+ * @param options Either the number of characters or the options to use. Defaults to `{ length: 1, allowLeadingZeros = false, exclude = [] }`.
311311 * @param options.length The number of digits to generate. Defaults to `1`.
312312 * @param options.allowLeadingZeros If true, leading zeros will be allowed. Defaults to `false`.
313- * @param options.bannedDigits An array of digits which should be banned in the generated string. Defaults to `[]`.
313+ * @param options.exclude An array of digits which should be excluded in the generated string. Defaults to `[]`.
314314 *
315315 * @example
316316 * faker.string.numeric() // '2'
317317 * faker.string.numeric(5) // '31507'
318318 * faker.string.numeric(42) // '56434563150765416546479875435481513188548'
319319 * faker.string.numeric({ length: 42, allowLeadingZeros: true }) // '00564846278453876543517840713421451546115'
320- * faker.string.numeric({ length: 6, bannedDigits : ['0'] }) // '943228'
320+ * faker.string.numeric({ length: 6, exclude : ['0'] }) // '943228'
321321 *
322322 * @since 8.0.0
323323 */
@@ -327,7 +327,7 @@ export class StringModule {
327327 | {
328328 length ?: number ;
329329 allowLeadingZeros ?: boolean ;
330- bannedDigits ?: readonly LiteralUnion < NumericChar > [ ] | string ;
330+ exclude ?: readonly LiteralUnion < NumericChar > [ ] | string ;
331331 } = { }
332332 ) : string {
333333 if ( typeof options === 'number' ) {
@@ -341,14 +341,14 @@ export class StringModule {
341341 return '' ;
342342 }
343343
344- let { bannedDigits = [ ] } = options ;
344+ let { exclude = [ ] } = options ;
345345
346- if ( typeof bannedDigits === 'string' ) {
347- bannedDigits = bannedDigits . split ( '' ) ;
346+ if ( typeof exclude === 'string' ) {
347+ exclude = exclude . split ( '' ) ;
348348 }
349349
350350 const allowedDigits = DIGIT_CHARS . filter (
351- ( digit ) => ! bannedDigits . includes ( digit )
351+ ( digit ) => ! exclude . includes ( digit )
352352 ) ;
353353
354354 if (
@@ -358,13 +358,13 @@ export class StringModule {
358358 allowedDigits [ 0 ] === '0' )
359359 ) {
360360 throw new FakerError (
361- 'Unable to generate numeric string, because all possible digits are banned .'
361+ 'Unable to generate numeric string, because all possible digits are excluded .'
362362 ) ;
363363 }
364364
365365 let result = '' ;
366366
367- if ( ! allowLeadingZeros && ! bannedDigits . includes ( '0' ) ) {
367+ if ( ! allowLeadingZeros && ! exclude . includes ( '0' ) ) {
368368 result += this . faker . helpers . arrayElement (
369369 allowedDigits . filter ( ( digit ) => digit !== '0' )
370370 ) ;
0 commit comments