Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

utils.gno

0.40 Kb · 20 lines
 1package uint256
 2
 3func checkNumberS(input string) error {
 4	const fn = "UnmarshalText"
 5	l := len(input)
 6	if l == 0 {
 7		return errEmptyString(fn, input)
 8	}
 9	if l < 2 || input[0] != '0' ||
10		(input[1] != 'x' && input[1] != 'X') {
11		return errMissingPrefix(fn, input)
12	}
13	if l == 2 {
14		return errEmptyNumber(fn, input)
15	}
16	if len(input) > 3 && input[2] == '0' {
17		return errLeadingZero(fn, input)
18	}
19	return nil
20}