Generate a random boolean value.
Rules:
() -> boolean
(number probability = 0.5) -> boolean
(string percentage) -> boolean
Examples:
// Ten percent's probability return true
@Bool(0.1);
@Bool('10%');
Generate a random float value.
Note: when you specified format to 2
, you may get a random value 0.10
, and the last 0
will be ignored, so you will get 0.1
eventually.
Rules:
() -> float
(string format = "1-4") -> float
(number max = 1) -> float
(number max = 1, string format = "1-4") -> float
(number min = 0, number max = 1) -> float
(number min = 0, number max = 1, string format = "1-4") -> float
(number min = 0, number max = 1, number format = "1-4") -> float
Examples:
@Float('2'); // generate value likes: 0.34
@Float(5, '1-3'); // generate value likes: 3.215 or 2.1 or 4.23
@Float(8, 9, '1'); // generate value likes: 8.2
Generate a random integer between min
to max
(include min
and max
).
Rules:
() -> integer
(int max = 1000) -> integer
(int min = 0, int max = 1000) -> integer
Examples:
@Int(); // return a integer between 0 - 1000
@Int(10); // return a integer between 0 - 10
@Int(10, 100); // return a integer between 10 - 100
Generator a random number value (can be a random float or integer value).
Rules:
() -> number
Generate a random character.
Available pre-defined pools: vowel
, hash
, consonant
, lower
, upper
, number
, symbol
, alpha
and all
- If parameter
pool
not in pre-defined pools, then itself will become a characters pool. - You can set
useAsPool
totrue
to force pre-defined pool key words to become a normal characters pool.
Rules:
() -> char
(string pool = "alpha") -> char
(string pool = "alpha", bool useAsPool = false) -> char
Examples:
@Char('vowel'); // will return random character in 'aeiou'
@Char('vowel', true); // will return random character in 'vowel'
Generate a random string.
- you can specified the string's character generate pool
- you can specified string length by setting
length
argument - you can set
min
andmax
to get a random length string which length is betweenmin
tomax
Rules:
() -> string
(string pool = "alpha") -> string
(int length) -> string
(string pool = "alpha", int length) -> string
(int min = 2, int max = 20) -> string
(string pool = "alpha", int min = 2, int max = 20) -> string
Generate a random timestamp or formatted date.
Caller | Description |
---|---|
@Date() | last ten year's random timestamp |
@Date(0) | last ten year to next ten year's random timestamp |
@Date(-2) | last two year's timestamp |
@Date(3) | next three year's timestamp |
@Date(-1, 3600) | next one hour's timestamp |
@Date("3600", "7200") | next one hour to next two hour's timestamp |
@Date("2011-1-1", "2011-12-31") | between 2011-1-1 00:00:00 to 2011-12-31 00:00:00 |
Default format is timestamp, you can specified date format in the first argument, for example:
@Date('YYYY-MM-DD HH:mm:ss', -2)
Date format reference:http://momentjs.com/docs/#/displaying/format/
Rules:
() -> string
(int flag = -10) -> string
(int flag = -10, nature range) -> string
(string format = "timestamp") -> string
(string format = "timestamp", int flag = -10) -> string
(string format = "timestamp", int flag = -10, nature range) -> string
(string from, string to) -> string
(string format = "timestamp", string from, string to) -> string
Generate a specified integer range.
Rules:
() -> array
(int stop = 10) -> array
(int start = 0, int stop = 10) -> array
(int start = 0, int stop = 10, int step = 1) -> array
Generate a rand auto increment id.
Rules:
() -> int
(int start = 1) -> int
(int start = 1, int step = 1) -> int
(string seed = "_d") -> int
(string seed = "_d", int start = 1) -> int
(string seed = "_d", int start = 1, int step = 1) -> int
Generate a random guid
format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
- x is replaced with a random hexadecimal digit from 0 to f
- y is replaced with a random hexadecimal digit from 8 to b
Rules:
() -> string
Generate a random object id
Rules:
() -> string
Generate a random md5 encrypted value.
Rules:
() -> string
Generate a random country in world
- setting
abbr
totrue
to return the country's shorthand name
Using config system.location.country
Rules:
() -> string
(bool abbr = false) -> string
Generate a random province in China
Using config system.location.region
Rules:
() -> string
Generate a random area in China
Using config system.location.area
Rules:
() -> string
Generate a random latitude float value
Rules:
() -> float
(int min = -90, int max = 90) -> float
(int fixed = 5) -> float
(int fixed = 5, int min = -90, int max = 90) -> float
Generate a random longitude float value
Rules:
() -> float
(int min = -180, int max = 180) -> float
(int fixed = 5) -> float
(int fixed = 5, int min = -180, int max = 180) -> float
Generate a random coordinates
Rules:
() -> string
Generate a random image url
Using config system.picture
Rules:
() -> string
(string category = "all") -> string
Using http://dummyimage.com to generate a random image
Rules:
() -> string
(string size) -> string
(string size, string text) -> string
(string size, string text, string colors) -> string
(int size) -> string
(int size, string text) -> string
(int size, string text, string colors) -> string
Using http://placehold.it to generate a random image
Rules:
() -> string
(string size) -> string
(string size, string text) -> string
(string size, string text, string colors) -> string
(int size) -> string
(int size, string text) -> string
(int size, string text, string colors) -> string
Using http://placeimg.com to generate a random image
Rules:
() -> string
(string size) -> string
(string size, string category) -> string
(string size, string category, string hue) -> string
(int size) -> string
(int size, string category) -> string
(int size, string category, string hue) -> string
Generate a random audio url
Using config system.audio
Rules:
() -> string
(string category = "all") -> string
Generate a random video url
Using config system.video
Rules:
() -> string
(string category = "all") -> string
Generate a random car type
Using config system.car.type
Rules:
() -> string
Generate a random car image
Using config system.picture.car
Rules:
() -> string
Generate a random Chinese word
Using config system.word.cn
Rules:
() -> string
Generate a random Chinese sentence
Rules:
() -> string
Generate a random Chinese paragraph
Rules:
(int length) -> string
() -> string
(int min = 3, int max = 7) -> string
Generate a random english word
Rules:
(int length) -> string
() -> string
(int min = 3, int max = 10) -> string
Generate a random english sentence
Rules:
(int length) -> string
() -> string
(int min = 12, int max = 18) -> string
Generate a random english paragraph
Rules:
(int length) -> string
() -> string
(int min = 3, int max = 7) -> string
Generate a random good word
Using config system.word.good
Rules:
() -> string
Generate a random ascii face string
Using config system.word.face
Rules:
() -> string
Generate a random gender string
category
can be'zh'
,'en'
and'short'
Using config system.user.gender
Rules:
() -> string
(string category = "en") -> string
Generate a random integer age
type
can be'child'
,'teen'
,'adult'
,'senior'
,'all'
Rules:
() -> integer
(string type) -> integer
Generate a random avatar url
Rules:
() -> string
Generate a random first name
gender
can be'male'
or'female'
Using config system.user.first
Rules:
() -> string
(string gender = "all") -> string
Generate a random last name
Using config system.user.last
Rules:
() -> string
Generate a random username
Rules:
() -> string
(bool middle = false) -> string
(string gender = "*") -> string
(string gender = "*", bool middle = false) -> string
(bool middle = false, string gender = "*") -> string
Generate a random chinese name
Rules:
() -> string
Generate a random nickname
Using config system.user.nick
Rules:
() -> string
Generate a random comment
Using config system.user.comment
Rules:
() -> string
Generate a random telephone
country
can be'fr'
,'uk'
,'us'
, default is'zh'
Rules:
() -> string
(bool format = false) -> string
(string country = "zh") -> string
(string country = "zh", bool format = false) -> string
Generate a random color value
Rules:
() -> string
(string format) -> string
Examples:
@Color(); // => some thing like: '#AB32F1'
@Color(short); // => some thing like: '#345'
@Color(rgb); // => some thing like: 'rgb(2, 10, 231)'
Generate a random domain
Rules:
() -> string
Generate a random email
Rules:
() -> string
Generate a random ip
Rules:
() -> string
Generate a random ipv6
Rules:
() -> string