Skip to main content

Scalar functions

string

Commentary

added in 0.0.5

Generates strings which may be templated with #{}, containing the names of variables or Java Faker expressions (Faker version 1.0.2). Vars will attempt to be resolved first.

Faker functions that take parameters must be invoked with single quotes and no spaces, as in #{Date.birthday '2','4'}. See the examples.

Valid expressions

Address.countyByZipCode
Address.fullAddress
Address.cityName
Address.citySuffix
Address.zipCodeByState
Address.streetSuffix
Address.streetPrefix
Address.latitude
Address.timeZone
Address.stateAbbr
Address.streetName
Address.buildingNumber
Address.firstName
Address.state
Address.zipCode
Address.streetAddress
Address.streetAddressNumber
Address.countryCode
Address.country
Address.lastName
Address.city
Address.longitude
Address.secondaryAddress
Address.cityPrefix
Ancient.primordial
Ancient.god
Ancient.hero
Ancient.titan
Animal.name
App.version
App.name
App.author
AquaTeenHungerForce.character
Artist.name
Avatar.image
Aviation.aircraft
Aviation.METAR
Aviation.airport
BackToTheFuture.character
BackToTheFuture.date
BackToTheFuture.quote
Beer.style
Beer.name
Beer.malt
Beer.hop
Beer.yeast
Book.genre
Book.title
Book.author
Book.publisher
Bool.bool
Buffy.celebrities
Buffy.episodes
Buffy.quotes
Buffy.bigBads
Buffy.characters
Business.creditCardNumber
Business.creditCardType
Business.creditCardExpiry
Cat.registry
Cat.name
Cat.breed
ChuckNorris.fact
Code.imei
Code.ean8
Code.gtin8
Code.isbnGs1
Code.isbn10
Code.asin
Code.ean13
Code.gtin13
Code.isbnRegistrant
Code.isbn13
Code.isbnGroup
Color.name
Color.hex
Commerce.promotionCode
Commerce.material
Commerce.department
Commerce.price
Commerce.productName
Commerce.color
Company.profession
Company.industry
Company.catchPhrase
Company.buzzword
Company.suffix
Company.logo
Company.name
Company.bs
Company.url
Country.capital
Country.countryCode2
Country.name
Country.flag
Country.countryCode3
Country.currencyCode
Country.currency
Crypto.md5
Crypto.sha256
Crypto.sha1
Crypto.sha512
Currency.code
Currency.name
Date.birthday
Date.future
Date.between
Date.past
Demographic.maritalStatus
Demographic.race
Demographic.demonym
Demographic.sex
Demographic.educationalAttainment
Dog.memePhrase
Dog.breed
Dog.name
Dog.sound
Dog.age
Dog.coatLength
Dog.gender
Dog.size
DragonBall.character
Dune.saying
Dune.character
Dune.planet
Dune.title
Dune.quote
Educator.university
Educator.campus
Educator.secondarySchool
Educator.course
ElderScrolls.quote
ElderScrolls.city
ElderScrolls.lastName
ElderScrolls.region
ElderScrolls.firstName
ElderScrolls.dragon
ElderScrolls.creature
ElderScrolls.race
Esports.game
Esports.league
Esports.event
Esports.player
Esports.team
File.fileName
File.mimeType
File.extension
Finance.bic
Finance.iban
Finance.creditCard
Food.dish
Food.spice
Food.ingredient
Food.vegetable
Food.measurement
Food.fruit
Food.sushi
Friends.location
Friends.character
Friends.quote
FunnyName.name
GameOfThrones.quote
GameOfThrones.city
GameOfThrones.character
GameOfThrones.house
GameOfThrones.dragon
Hacker.adjective
Hacker.noun
Hacker.verb
Hacker.ingverb
Hacker.abbreviation
HarryPotter.location
HarryPotter.book
HarryPotter.house
HarryPotter.character
HarryPotter.spell
HarryPotter.quote
Hipster.word
HitchhikersGuideToTheGalaxy.location
HitchhikersGuideToTheGalaxy.planet
HitchhikersGuideToTheGalaxy.specie
HitchhikersGuideToTheGalaxy.marvinQuote
HitchhikersGuideToTheGalaxy.quote
HitchhikersGuideToTheGalaxy.starship
HitchhikersGuideToTheGalaxy.character
Hobbit.thorinsCompany
Hobbit.location
Hobbit.quote
Hobbit.character
HowIMetYourMother.catchPhrase
HowIMetYourMother.quote
HowIMetYourMother.character
HowIMetYourMother.highFive
IdNumber.valid
IdNumber.invalid
IdNumber.invalidSvSeSsn
IdNumber.ssnValid
IdNumber.validSvSeSsn
Internet.domainSuffix
Internet.image
Internet.avatar
Internet.ipV4Cidr
Internet.publicIpV4Address
Internet.domainName
Internet.password
Internet.ipV6Cidr
Internet.userAgentAny
Internet.userAgent
Internet.emailAddress
Internet.safeEmailAddress
Internet.macAddress
Internet.privateIpV4Address
Internet.ipV6Address
Internet.url
Internet.ipV4Address
Internet.domainWord
Internet.uuid
Internet.slug
Job.seniority
Job.field
Job.title
Job.keySkills
Job.position
LeagueOfLegends.location
LeagueOfLegends.champion
LeagueOfLegends.masteries
LeagueOfLegends.quote
LeagueOfLegends.rank
LeagueOfLegends.summonerSpell
Lebowski.character
Lebowski.actor
Lebowski.quote
LordOfTheRings.character
LordOfTheRings.location
Lorem.sentence
Lorem.sentences
Lorem.character
Lorem.characters
Lorem.paragraphs
Lorem.paragraph
Lorem.fixedString
Lorem.word
Lorem.words
Matz.quote
Medical.hospitalName
Medical.medicineName
Medical.symptoms
Medical.diseaseName
Music.key
Music.instrument
Music.genre
Music.chord
Name.title
Name.name
Name.suffix
Name.lastName
Name.nameWithMiddle
Name.fullName
Name.firstName
Name.prefix
Name.username
Name.bloodGroup
Nation.flag
Nation.language
Nation.nationality
Nation.capitalCity
Number.randomNumber
Number.randomDouble
Number.digits
Number.digit
Number.randomDigitNotZero
Number.numberBetween
Number.randomDigit
Options.nextElement
Options.option
Overwatch.quote
Overwatch.location
Overwatch.hero
PhoneNumber.extension
PhoneNumber.cellPhone
PhoneNumber.subscriberNumber
PhoneNumber.phoneNumber
Pokemon.location
Pokemon.name
PrincessBride.quote
PrincessBride.character
ProgrammingLanguage.name
ProgrammingLanguage.creator
Relationships.spouse
Relationships.inLaw
Relationships.sibling
Relationships.extended
Relationships.parent
Relationships.any
Relationships.direct
RickAndMorty.quote
RickAndMorty.character
RickAndMorty.location
Robin.quote
RockBand.name
Shakespeare.asYouLikeItQuote
Shakespeare.hamletQuote
Shakespeare.kingRichardIIIQuote
Shakespeare.romeoAndJulietQuote
SlackEmoji.emoji
SlackEmoji.celebration
SlackEmoji.nature
SlackEmoji.objectsAndSymbols
SlackEmoji.foodAndDrink
SlackEmoji.activity
SlackEmoji.custom
SlackEmoji.travelAndPlaces
SlackEmoji.people
Space.nasaSpaceCraft
Space.galaxy
Space.meteorite
Space.star
Space.agencyAbbreviation
Space.constellation
Space.company
Space.nebula
Space.distanceMeasurement
Space.moon
Space.agency
Space.starCluster
Space.planet
StarTrek.location
StarTrek.villain
StarTrek.character
StarTrek.specie
Stock.nyseSymbol
Stock.nsdqSymbol
Superhero.descriptor
Superhero.name
Superhero.power
Superhero.suffix
Superhero.prefix
Team.name
Team.creature
Team.state
Team.sport
TwinPeaks.character
TwinPeaks.location
TwinPeaks.quote
University.suffix
University.name
University.prefix
Weather.temperatureFahrenheit
Weather.temperatureCelsius
Weather.description
Witcher.quote
Witcher.character
Witcher.witcher
Witcher.monster
Witcher.school
Witcher.location
Yoda.quote
Zelda.character
Zelda.game

Examples

Generating string values

Use any of the valid Faker expressions in #{}.

{
"_gen": "string",
"expr": "#{Name.fullName}"
}
[
"Ms. Shakira McLaughlin",
"Miss Marshall Von",
"Tiffani Schaden",
"Frederick Schoen",
"Melda Cartwright"
]

Referring to vars

Refer to variables defined in vars or varsOnce. These are given preference over Faker expressions, but both can be resolved in the same string.

{
"topic": "sandbox",
"vars": {
"n": {
"_gen": "uniformDistribution",
"bounds": [
1,
10
],
"decimals": 0
}
},
"value": {
"_gen": "string",
"expr": "The magic number is #{n}"
}
}
[
"The magic number is 1",
"The magic number is 6",
"The magic number is 8",
"The magic number is 5",
"The magic number is 3"
]

Calling Faker functions

Some Faker expressions are functions that take parameters. When there's a first-class ShadowTraffic alternative function, you should use they're much less finicky to use. But if you have to, invoke them with single quotes, commas between parameters, and no spaces.

{
"_gen": "string",
"expr": "#{Date.birthday '2','4'}"
}
[
"Wed Apr 06 15:54:45 PDT 2022",
"Wed Mar 16 23:33:52 PDT 2022",
"Tue Jan 18 17:57:04 PST 2022",
"Tue Mar 16 00:39:59 PDT 2021",
"Thu May 13 22:18:11 PDT 2021"
]

Specification

JSON schema

{
"type": "object",
"properties": {
"expr": {
"type": "string"
}
},
"required": [
"expr"
]
}