mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
restore edit form validation
This commit is contained in:
parent
34e5fe4b2b
commit
0981aeb38c
@ -1,36 +1,11 @@
|
|||||||
import { FileInfo } from '@oceanprotocol/lib'
|
import { FileInfo } from '@oceanprotocol/lib'
|
||||||
import { validateFieldSchaclSchema } from '@utils/schaclSchema'
|
|
||||||
import * as Yup from 'yup'
|
import * as Yup from 'yup'
|
||||||
|
|
||||||
export const validationSchema = Yup.object().shape({
|
export const validationSchema = Yup.object().shape({
|
||||||
name: Yup.string()
|
name: Yup.string()
|
||||||
.required('Required')
|
.min(4, (param) => `Title must be at least ${param.min} characters`)
|
||||||
.test(async (value, { path, createError }): Promise<any> => {
|
.required('Required'),
|
||||||
if (!value) return
|
description: Yup.string().required('Required').min(10),
|
||||||
const keyField = path.split('.')[0]
|
|
||||||
const valueField = path.split('.')[1]
|
|
||||||
|
|
||||||
return await validateFieldSchaclSchema(
|
|
||||||
keyField,
|
|
||||||
valueField,
|
|
||||||
value,
|
|
||||||
createError
|
|
||||||
)
|
|
||||||
}),
|
|
||||||
description: Yup.string()
|
|
||||||
.required('Required')
|
|
||||||
.test(async (value, { path, createError }): Promise<any> => {
|
|
||||||
if (!value) return
|
|
||||||
const keyField = path.split('.')[0]
|
|
||||||
const valueField = path.split('.')[1]
|
|
||||||
|
|
||||||
return await validateFieldSchaclSchema(
|
|
||||||
keyField,
|
|
||||||
valueField,
|
|
||||||
value,
|
|
||||||
createError
|
|
||||||
)
|
|
||||||
}),
|
|
||||||
price: Yup.number().required('Required'),
|
price: Yup.number().required('Required'),
|
||||||
files: Yup.array<FileInfo[]>()
|
files: Yup.array<FileInfo[]>()
|
||||||
.of(
|
.of(
|
||||||
@ -49,20 +24,8 @@ export const validationSchema = Yup.object().shape({
|
|||||||
)
|
)
|
||||||
.nullable(),
|
.nullable(),
|
||||||
timeout: Yup.string().required('Required'),
|
timeout: Yup.string().required('Required'),
|
||||||
author: Yup.string()
|
author: Yup.string().nullable(),
|
||||||
.required('Required')
|
tags: Yup.array<string[]>().nullable()
|
||||||
.test(async (value, { path, createError }): Promise<any> => {
|
|
||||||
if (!value) return
|
|
||||||
const keyField = path.split('.')[0]
|
|
||||||
const valueField = path.split('.')[1]
|
|
||||||
|
|
||||||
return await validateFieldSchaclSchema(
|
|
||||||
keyField,
|
|
||||||
valueField,
|
|
||||||
value,
|
|
||||||
createError
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export const computeSettingsValidationSchema = Yup.object().shape({
|
export const computeSettingsValidationSchema = Yup.object().shape({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user