Skip to content

Commit

Permalink
feat[form]: Yup add reg
Browse files Browse the repository at this point in the history
  • Loading branch information
ybgbob committed May 31, 2024
1 parent 22e9ebe commit 7c8c464
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/form/ListForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ interface FormValues {
}

const ListSchema = Yup.object().shape({
name: Yup.string().required('Name is required').max(30),
name: Yup.string()
.required('Name is required')
.matches(
/^[^\\\/'"\s]*$/,
'Strings cannot contain symbols such as spaces or slashes',
)
// .matches(/^[a-z]+$/, '只能包含小写字母 a-z')
.max(15),
price: Yup.number()
.positive()
.required('Price is required')
Expand Down

0 comments on commit 7c8c464

Please sign in to comment.