mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 12:14:41 +01:00
feat(Form): add superstruct validation (#2363)
Co-authored-by: Benjamin Canac <canacb1@gmail.com> Co-authored-by: Romain Hamel <rom.hml@gmail.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import { z } from 'zod'
|
||||
import * as yup from 'yup'
|
||||
import Joi from 'joi'
|
||||
import * as valibot from 'valibot'
|
||||
import { object, string, nonempty, refine } from 'superstruct'
|
||||
import ComponentRender from '../component-render'
|
||||
import type { FormProps, FormSlots } from '../../src/runtime/components/Form.vue'
|
||||
import { renderForm } from '../utils/form'
|
||||
@@ -65,6 +66,15 @@ describe('Form', () => {
|
||||
}))
|
||||
}
|
||||
],
|
||||
['superstruct', {
|
||||
schema: object({
|
||||
email: nonempty(string()),
|
||||
password: refine(string(), 'Password', (value) => {
|
||||
if (value.length >= 8) return true
|
||||
return 'Must be at least 8 characters'
|
||||
})
|
||||
})
|
||||
}],
|
||||
['custom', {
|
||||
async validate(state: any) {
|
||||
const errs = []
|
||||
|
||||
Reference in New Issue
Block a user