2018-01-15 18:42:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
import
|
|
|
|
strformat,
|
2018-01-22 22:23:07 +00:00
|
|
|
errors, constants, bigints
|
2018-01-15 18:42:40 +00:00
|
|
|
|
|
|
|
proc validateCanonicalAddress*(value: cstring, title: string = "Value") =
|
2018-01-24 13:31:24 +00:00
|
|
|
# TODO
|
|
|
|
if false: #len(value) != 20:
|
2018-01-15 18:42:40 +00:00
|
|
|
raise newException(ValidationError,
|
|
|
|
fmt"{title} {value} is not a valid canonical address")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proc validateGte*(value: Int256, minimum: int, title: string = "Value") =
|
2018-01-22 22:23:07 +00:00
|
|
|
if value <= minimum.int256:
|
2018-01-17 14:16:00 +00:00
|
|
|
raise newException(ValidationError,
|
|
|
|
fmt"{title} {value} is not greater than or equal to {minimum}")
|
|
|
|
|
|
|
|
proc validateGt*(value: Int256, minimum: int, title: string = "Value") =
|
2018-01-22 22:23:07 +00:00
|
|
|
if value < minimum.int256:
|
2018-01-15 18:42:40 +00:00
|
|
|
raise newException(ValidationError,
|
|
|
|
fmt"{title} {value} is not greater than or equal to {minimum}")
|
2018-01-17 14:16:00 +00:00
|
|
|
|
|
|
|
proc validateGt*(value: int, minimum: int, title: string = "Value") =
|
|
|
|
if value < minimum:
|
|
|
|
raise newException(ValidationError,
|
|
|
|
fmt"{title} {value} is not greater than or equal to {minimum}")
|