validator
Index
Namespaces
Classes
Type Aliases
Variables
Functions
- checkAddressCheckSum
- isAddress
- isBigInt
- isBlockNumber
- isBlockNumberOrTag
- isBlockTag
- isBloom
- isBoolean
- isBuffer
- isBytes
- isContractAddressInBloom
- isFilterObject
- isHex
- isHexStrict
- isHexString32Bytes
- isHexString8Bytes
- isInBloom
- isInt
- isNullish
- isNumber
- isObject
- isString
- isTopic
- isTopicInBloom
- isUInt
- isUserEthereumAddressInBloom
- isValidEthBaseType
Namespaces
utils
abiSchemaToJsonSchema
Parameters
abis: FullValidationSchema | ShortValidationSchema
optionallevel: string
Returns JsonSchema
codePointToInt
Parameters
codePoint: number
Returns number
ethAbiToJsonSchema
Parameters
abis: ValidationSchemaInput
Returns JsonSchema
fetchArrayElement
Parameters
data: unknown[]
level: number
Returns unknown
hexToNumber
Converts value to it’s number representation
Parameters
value: string
Returns number | bigint
numberToHex
Converts value to it’s hex representation
Parameters
value: ValidInputTypes
Returns string
padLeft
Adds a padding on the left of a string, if value is a integer or bigInt will be converted to a hex string.
Parameters
value: ValidInputTypes
characterAmount: number
optionalsign: string
Returns string
parseBaseType
Type parameters
- T = string
Parameters
type: string
Returns { arraySizes: number[]; baseType?: T; baseTypeSize: undefined | number; isArray: boolean }
arraySizes: number[]
optionalbaseType?: T
baseTypeSize: undefined | number
isArray: boolean
transformJsonDataToAbiFormat
Parameters
abis: FullValidationSchema
data: Record<string, unknown> | readonly unknown[]
optionaltransformedData: unknown[]
Returns unknown[]
Classes
Web3Validator
constructor
Returns Web3Validator
validate
Parameters
schema: ValidationSchemaInput
data: readonly unknown[]
optionaloptions: Web3ValidationOptions
Returns undefined | Web3ValidationErrorObject[]
validateJSONSchema
Parameters
schema: object
data: object
optionaloptions: Web3ValidationOptions
Returns undefined | Web3ValidationErrorObject[]
Web3ValidatorError
constructor
Parameters
errors: Web3ValidationErrorObject[]
Returns Web3ValidatorError
code
readonlyerrors
innerError
readonlyname
stack
toJSON
Returns { code: number; innerError: undefined | Error | Error[]; message: string; name: string }
code: number
innerError: undefined | Error | Error[]
message: string
name: string
staticconvertToString
Parameters
value: unknown
optionalunquotValue: boolean
Returns string
Type Aliases
EthBaseTypes
EthBaseTypesWithMeta
EthExtendedTypes
FullValidationSchema
JsonSchema
ShortValidationSchema
ValidInputTypes
ValidationSchemaInput
Web3ValidationErrorObject
Web3ValidationOptions
Type declaration
readonlysilent: boolean
Variables
constVALID_ETH_BASE_TYPES
constvalidator
Functions
checkAddressCheckSum
Checks the checksum of a given address. Will also return false on non-checksum addresses.
Parameters
data: string
Returns boolean
isAddress
Checks if a given string is a valid Ethereum address. It will also check the checksum, if the address has upper and lowercase letters.
Parameters
value: ValidInputTypes
optionalcheckChecksum: boolean
Returns boolean
isBigInt
Checks if a given value is a valid big int
Parameters
value: ValidInputTypes
Returns boolean
isBlockNumber
Parameters
value: string | number | bigint
Returns boolean
isBlockNumberOrTag
Returns true if given value is valid hex string and not negative, or is a valid BlockTag
Parameters
value: string | number | bigint
Returns boolean
isBlockTag
Returns true if the given blockNumber is ‘latest’, ‘pending’, ‘earliest, ‘safe’ or ‘finalized’
Parameters
value: string
Returns boolean
isBloom
Returns true if the bloom is a valid bloom https://github.com/joshstevens19/ethereum-bloom-filters/blob/fbeb47b70b46243c3963fe1c2988d7461ef17236/src/index.ts#L7
Parameters
bloom: ValidInputTypes
Returns boolean
isBoolean
Parameters
value: ValidInputTypes
Returns boolean
isBuffer
checks input if typeof data is valid buffer input
Parameters
data: ValidInputTypes
Returns boolean
isBytes
Parameters
value: Uint8Array | number[] | ValidInputTypes
optionaloptions: { abiType: string; size?: undefined } | { abiType?: undefined; size: number }
Returns boolean
isContractAddressInBloom
Returns true if the contract address is part of the given bloom. note: false positives are possible.
Parameters
bloom: string
contractAddress: string
Returns boolean
isFilterObject
First we check if all properties in the provided value are expected, then because all Filter properties are optional, we check if the expected properties are defined. If defined and they’re not the expected type, we immediately return false, otherwise we return true after all checks pass.
Parameters
value: Filter
Returns boolean
isHex
Parameters
hex: ValidInputTypes
Returns boolean
isHexStrict
Parameters
hex: ValidInputTypes
Returns boolean
isHexString32Bytes
Parameters
value: string
optionalprefixed: boolean
Returns boolean
isHexString8Bytes
Parameters
value: string
optionalprefixed: boolean
Returns boolean
isInBloom
Returns true if the value is part of the given bloom note: false positives are possible.
Parameters
bloom: string
value: string | Uint8Array
Returns boolean
isInt
Parameters
value: ValidInputTypes
optionaloptions: { abiType: string; bitSize?: undefined } | { abiType?: undefined; bitSize: number }
Returns boolean
isNullish
Parameters
item: unknown
Returns item is undefined | null
isNumber
Parameters
value: ValidInputTypes
Returns boolean
isObject
Parameters
item: unknown
Returns item is Record<string, unknown>
isString
checks input if typeof data is valid string input
Parameters
value: ValidInputTypes
Returns boolean
isTopic
Checks if its a valid topic
Parameters
topic: string
Returns boolean
isTopicInBloom
Returns true if the topic is part of the given bloom. note: false positives are possible.
Parameters
bloom: string
topic: string
Returns boolean
isUInt
Parameters
value: ValidInputTypes
optionaloptions: { abiType: string; bitSize?: undefined } | { abiType?: undefined; bitSize: number }
Returns boolean
isUserEthereumAddressInBloom
Returns true if the ethereum users address is part of the given bloom note: false positives are possible.
Parameters
bloom: string
ethereumAddress: string
Returns boolean
isValidEthBaseType
Parameters
type: string
Returns boolean
Code points to int