console.log('-- 校验emall ')
try {
const EmailSchema = v.pipe(v.string(), v.email())
const email = v.parse(EmailSchema, '')
console.log('email ===>', email)
} catch (error) {
console.log(error)
}
const StringArraySchema = v.array(v.string(), 'An array is required.')
const ObjectArraySchema = v.array(v.object({ key: v.string() }))
const theTestStringArr = ['111', '123', '123']
const theTestObjArr = [
{ key: 'key', value: 'value' },
{
key: '111',
value: '222',
},
]
console.log(
'ObjectArraySchema ===>',
v.parse(StringArraySchema, theTestStringArr),
)
console.log(
'ObjectArraySchema ===>',
v.parse(ObjectArraySchema, theTestObjArr),
)