Documentation ¶
Overview ¶
Package validate provides tools to validate command line (or Request) input
Index ¶
- Constants
- Variables
- func HasArticulationKey(on bool) bool
- func IsBlockHash(str string) bool
- func IsBlockNumber(str string) (bool, blknum_t)
- func IsBlockNumberList(strs []string) (bool, []blknum_t)
- func IsDateTimeString(str string) bool
- func IsRange(chain, str string) (bool, error)
- func IsTimestamp(str string) (bool, blknum_t)
- func IsTransBlockHashAndId(str string) bool
- func IsTransBlockNumAndId(strIn string) bool
- func IsTransHash(str string) bool
- func IsTransIndex(str string) bool
- func IsValidBlockId(chain string, ids []string, validTypes ValidArgumentType) (bool, error)
- func IsValidFourByte(val string) bool
- func IsValidFourByteE(val string) (bool, error)
- func IsValidHash(hash string) bool
- func IsValidTopic(val string) bool
- func IsValidTopicE(val string) (bool, error)
- func IsValidTransId(chain string, ids []string, validTypes ValidArgumentType) (bool, error)
- func ToIsoDateStr2(dateStr string) string
- func Usage(msg string, values ...string) error
- func ValidateAddresses(args []string) error
- func ValidateAtLeastOneAddr(args []string) error
- func ValidateAtLeastOneNonSentinal(args []string) error
- func ValidateEnum(field, value, valid string) error
- func ValidateEnumRequired(field, value, valid string) error
- func ValidateEnumSlice(field string, values []string, valid string) error
- func ValidateExactlyOneAddr(args []string) error
- func ValidateIdentifiers(chain string, ids []string, validTypes ValidArgumentType, maxRanges int, ...) error
- func ValidateIdentifiersWithBounds(chain string, ids []string, validTypes ValidArgumentType, maxRanges int, ...) (base.BlockRange, error)
- type InvalidIdentifierLiteralError
- type ValidArgumentType
Constants ¶
const ValidBlockId = ValidArgumentBlockHash | ValidArgumentBlockNumber | ValidArgumentTimestamp | ValidArgumentSpecialBlock
const ValidBlockIdWithRange = ValidBlockId | ValidArgumentRange
const ValidBlockIdWithRangeAndDate = ValidBlockIdWithRange | ValidArgumentDate
const ValidTransId = ValidArgumentTransHash | ValidArgumentTransBlockNumberAndId | ValidArgumentTransBlockHashAndId
Variables ¶
var ErrTooManyRanges = errors.New("too many ranges")
Functions ¶
func HasArticulationKey ¶
HasArticulationKey returns true if the articulation key is present
func IsBlockHash ¶
func IsBlockNumber ¶
func IsBlockNumberList ¶
func IsDateTimeString ¶
func IsTimestamp ¶
func IsTransBlockHashAndId ¶
func IsTransBlockNumAndId ¶
func IsTransHash ¶
func IsTransIndex ¶
func IsValidBlockId ¶
func IsValidBlockId(chain string, ids []string, validTypes ValidArgumentType) (bool, error)
func IsValidFourByte ¶
func IsValidFourByteE ¶
func IsValidHash ¶
func IsValidTopic ¶
func IsValidTopicE ¶
func IsValidTransId ¶
func IsValidTransId(chain string, ids []string, validTypes ValidArgumentType) (bool, error)
func ToIsoDateStr2 ¶
func ValidateAddresses ¶
func ValidateAtLeastOneAddr ¶
func ValidateEnum ¶
func ValidateEnumRequired ¶
func ValidateExactlyOneAddr ¶
func ValidateIdentifiers ¶
func ValidateIdentifiers(chain string, ids []string, validTypes ValidArgumentType, maxRanges int, results *[]identifiers.Identifier) error
ValidateIdentifiers validates multiple identifiers against multiple valid types (specified as bitmasks). If any of the identifiers are invalid, it returns error If all identifiers are valid, it returns nil
Examples:
ValidateIdentifiers(identifiers, ValidArgumentBlockNumber | ValidArgumentDate, 0) ValidateIdentifiers(identifiers, ValidArgumentRange, 1)
This routine can be used for both block identifiers and transaction
func ValidateIdentifiersWithBounds ¶
func ValidateIdentifiersWithBounds(chain string, ids []string, validTypes ValidArgumentType, maxRanges int, results *[]identifiers.Identifier) (base.BlockRange, error)
ValidateIdentifiersWithBounds Is a helper function to return bounds in addition to validating identifiers
Types ¶
type InvalidIdentifierLiteralError ¶
func (*InvalidIdentifierLiteralError) Error ¶
func (e *InvalidIdentifierLiteralError) Error() string
type ValidArgumentType ¶
type ValidArgumentType uint16
ValidArgumentType is a bitmask used to make it easier to validate multiple block identifiers (which usually are arguments to `chifra` commands). This way we can specify that we want e.g. both block number and a special block as valid arguments
const ( ValidArgumentBlockHash ValidArgumentType = 1 << iota ValidArgumentBlockNumber ValidArgumentTimestamp ValidArgumentDate ValidArgumentRange ValidArgumentSpecialBlock ValidArgumentTransHash ValidArgumentTransBlockNumberAndId ValidArgumentTransBlockHashAndId )