Guoguo-notes
主页
  • 常用笔记
  • 飞码篇
  • Java
  • React笔记
  • 袁果锅生态
GitHub
主页
  • 常用笔记
  • 飞码篇
  • Java
  • React笔记
  • 袁果锅生态
GitHub
  • 常用笔记

    • CSS 封装.md
    • CSS笔记.md
    • Echarts.md
    • Element Plus --vue3.0.md
    • Element ui 笔记.md
    • Git 代码管理.md
    • Html 笔记.md
    • Taro.md
    • TypeScript.md
    • Vue 代码片段.md
    • Vue 全局封装 main.js.md
    • Vue 笔记.md
    • Vue3 .md
    • Vue3+Element Plus.md
    • axios 请求拦截.md
    • ecahrts 使用地图报错问题.md
    • element plus 本地启动.md
    • jsx tsx 代码片段.md
    • jsx tsx 笔记.md
    • js常规.md
    • npm.md
    • sh 笔记.md
    • uniapp笔记.md
    • valibot校验学习.md
    • vite 笔记.md
    • vite手写插件.md
    • vue.js 下载文件.md
    • vueuse笔记.md
    • vxe-table笔记.md
    • 云开发教程.md
    • 公共API接口.md
    • 小程序笔记.md
    • 常用插件.md
    • 插件库.md
    • 服务器.md
    • 服务器部署教学.md
    • 毕业设计接单.md
    • 汇智腾远笔记.md
    • 浏览器px to rem适配.md
    • 登录流程.md
    • 登录逻辑.md
    • 网站配色.md
    • 视频播放插件.md
    • 解析数学公式.md
    • 跨域代理.md

parse

校验 email

    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),
      )
Edit this page
Last Updated:
Contributors: 袁果锅
Prev
uniapp笔记.md
Next
vite 笔记.md