You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Generator for combining faker methods based on a static string input or an array of static string inputs.
593
+
*
594
+
* Note: We recommend using string template literals instead of `fake()`,
595
+
* which are faster and strongly typed (if you are using TypeScript),
596
+
* e.g. ``const address = `${faker.location.zipCode()} ${faker.location.city()}`;``
597
+
*
598
+
* This method is useful if you have to build a random string from a static, non-executable source
599
+
* (e.g. string coming from a user, stored in a database or a file).
600
+
*
601
+
* It checks the given string for placeholders and replaces them by calling faker methods:
602
+
*
603
+
* ```js
604
+
* const hello = faker.helpers.fake('Hi, my name is {{person.firstName}} {{person.lastName}}!');
605
+
* ```
606
+
*
607
+
* This would use the `faker.person.firstName()` and `faker.person.lastName()` method to resolve the placeholders respectively.
608
+
*
609
+
* It is also possible to provide parameters. At first, they will be parsed as json,
610
+
* and if that isn't possible, it will fall back to string:
611
+
*
612
+
* ```js
613
+
* const message = faker.helpers.fake('You can call me at {{phone.number(+!# !## #### #####!)}}.');
614
+
* ```
615
+
*
616
+
* It is also possible to use multiple parameters (comma separated).
617
+
*
618
+
* ```js
619
+
* const message = faker.helpers.fake('Your pin is {{string.numeric(4, {"allowLeadingZeros": true})}}.');
620
+
* ```
621
+
*
622
+
* It is also NOT possible to use any non-faker methods or plain javascript in such patterns.
623
+
*
624
+
* @param pattern The pattern string that will get interpolated. Must not be empty. If an array is passed, a random element will be picked and interpolated.
625
+
*
626
+
* @see faker.helpers.mustache() to use custom functions for resolution.
0 commit comments