Refining Validation
Built-in Refinements
import { assert, pattern, string } from 'superstruct'
const Section = pattern(string(), /\d+(\.\d+/)?/)
assert('2', Section) // passes
assert('2.1', Section) // passes
assert('string', Section) // throws!import { assert, size, string } from 'superstruct'
const Name = size(string(), 1, 100)
assert('Alex', Name) // passes
assert('', Name) // throws!Custom Refinements
Last updated