GitHub

Supported Scalars

Please visit validator.js for documentation and specifics of individual validators

  • Not all validators in validator.js are implemented.
  • DateTime is an additional validation

Available scalars

Includes mock generators when built-in support is available. When a field is marked as a scalar, a mock generator function is created. The list below indicates which function from faker.js it maps to, when available. Scalars marked as - generate the mock function scaffolding, and will require providing custom generators.

ScalarMockDescription
1Alphafaker.random.alphaString contains only letters (a-zA-Z). Locale picked from context
2Alphanumericfaker.ransom.alphaNumericString contains only letters and numbers (a-zA-Z0-9)
3Asciifaker.random.alphaString contains ASCII chars only
4Base32-String is base32 encoded
5Base58-String is base58 encoded
6Base64-String is base64 encoded. ([url safe](https://base
7BIC-String is a BIC (Bank Identification Code) or SWIFT code
8BtcAddressfaker.finance.bitcoinAddressString is a valid BTC address
9ByteLength-String is of length (in UTF-8 bytes) falls in a range
10CreditCardfaker.finance.creditCardNumberString is a credit card
11Currencyfaker.finance.amountString is a valid currency amount
12DataURIfaker.image.dataUriString is a data uri format
13Datefaker.date.pastString is a valid date.e.g. [2002-07-15, new Date()]
14DateTimefaker.datatype.datetimeString is a valid Prisma DateTime (ISO 8601, strict-mode date)
15EAN-String is an EAN (European Article Number)
16Emailfaker.internet.emailString is an email
17Emptybuilt-inString has a length of zero
18EthereumAddressfaker.finance.ethereumAddressString is an Ethereum address using basic regex. Does not validate address checksums
19FQDNfaker.internet.domainNameString is a fully qualified domain name (e.g. domain.com)
20FullWidth-String contains any full-width chars
21HalfWidth-String contains any half-width chars
22HashMd4built-inString is a hash of type algorithm
23HashMd5built-inString is a hash of type 'md5'
24HashSha1built-inString is a hash of type 'sha1'
25HashSha256built-inString is a hash of type 'sha256'
26HashSha384built-inString is a hash of type 'sha384'
27HashSha512built-inString is a hash of type 'sha512'
28HashRipemd128-String is a hash of type 'ripemd128'
29HashRipemd160-String is a hash of type 'ripemd160'
30HashTiger128-String is a hash of type 'tiger128'
31HashTiger160-String is a hash of type 'tiger160'
32HashTiger192-String is a hash of type 'tiger192'
33HashCrc32-String is a hash of type 'crc32'
34HashCrc32b-String is a hash of type 'crc32b'
35Hexadecimalfaker.datatype.hexaDecimalString is a hexadecimal number
36HexColorbuilt-inString is a hexadecimal color
37HSLbuilt-inString is an HSL (hue, saturation, lightness, optional alpha)
38IBANfaker.finance.ibanString is a IBAN (International Bank Account Number)
39IPfaker.internet.ipString is an IP (version 4 or 6) (version==undefined => either)
40IPv4faker.internet.ipString is an IP (version 4 or 6) (version==undefined => either)
41IPv6faker.internet.ipv6String is an IP (version 4 or 6) (version==undefined => either)
42IPRange-String is an IP Range (version 4 or 6) (version==undefined => either)
43ISBN-String is an ISBN (version 10 or 13) (version==undefined => either)
44ISIN-String is an [ISIN][ISIN] (stock/security identifier)
45ISO8601-String is a valid ISO 8601 date
46ISO31661Alpha2-String is a valid ISO 3166-1 alpha-2 officially assigned country code
47ISO31661Alpha3-String is a valid ISO 3166-1 alpha-3 officially assigned country code
48ISRC-String is a ISRC
49ISSN-String is an ISSN
50Jsonfaker.datatype.jsonString is valid JSON (note: uses JSON.parse)
51JWT-String is valid JWT token
52LatLongbuilt-inString is a valid latitude-longitude coordinate in the format lat, long or lat, long
53Length-String's length falls in a range
54Localefaker.random.localeString is a locale
55Lowercasebuilt-inString is lowercase
56MACAddressfaker.internet.macString is a MAC address
57MimeTypefaker.system.mimeTypeString matches to a valid MIME type format
58MobilePhonefaker.phone.phoneNumberString is a mobile phone number
59MongoId-String is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid]
60Multibyte-String contains one or more multibyte chars
61Numericfaker.datatype.numberString contains only numbers
62Octalbuilt-inString is a valid octal number
63PassportNumber-String is a valid passport number
64Portfaker.internet.portString is a valid port number
65PostalCodefaker.address.zipCodeString is a postal code
66RFC3339-String is a valid RFC 3339 date
67RgbColorbuilt-inString is a rgb or rgba color
68SemVerfaker.system.semverString is a Semantic Versioning Specification (SemVer)
69SurrogatePair-String contains any surrogate pairs chars
70Uppercasebuilt-inString is uppercase
71Slugfaker.lorem.slugString is of type slug
72StrongPasswordfaker.internet.passwordString is strong password or not. Allows for custom requirements or scoring rules. If returnScore is true, then the function returns an integer score for the password rather than a boolean
73URLfaker.internet.urlString is an URL
74UUIDfaker.datatype.uuidString is a UUID (version 3, 4 or 5)
75VariableWidth-String contains a mixture of full and half-width chars
76VAT-String is a valid VAT number