additional validation in create project

This commit is contained in:
Barry Gitarts 2019-08-28 10:56:30 -04:00 committed by Barry G
parent f7d43a7870
commit 919d4c087d
1 changed files with 9 additions and 3 deletions

View File

@ -34,7 +34,10 @@ const helperText = 'The length of time the Project has to veto when the project
const generateChatRoom = title => `#status-${title.replace(/\s/g, '')}` const generateChatRoom = title => `#status-${title.replace(/\s/g, '')}`
const validationSchema = Yup.object().shape({ const validationSchema = Yup.object().shape({
title: Yup.string().max(20, TOO_LONG).required(REQUIRED) title: Yup.string().max(20, TOO_LONG).required(REQUIRED),
subtitle: Yup.string().max(120, TOO_LONG),
creator: Yup.string().required(REQUIRED),
goal: Yup.number().required(REQUIRED).positive().integer()
}); });
const styles = theme => ({ const styles = theme => ({
@ -269,8 +272,8 @@ const SubmissionSection = ({ classes, history }) => {
name="title" name="title"
label="Project Name" label="Project Name"
bottomRightLabel="Max 20" bottomRightLabel="Max 20"
bottomRightError={errors.title === TOO_LONG} bottomRightError={touched.title && errors.title === TOO_LONG}
errorBorder={errors.title === REQUIRED} errorBorder={touched.title && errors.title === REQUIRED}
placeholder="e.g. Tribute to Talk or Bob" placeholder="e.g. Tribute to Talk or Bob"
onChange={handleChange} onChange={handleChange}
onBlur={handleBlur} onBlur={handleBlur}
@ -282,6 +285,7 @@ const SubmissionSection = ({ classes, history }) => {
name="subtitle" name="subtitle"
label="Short Description" label="Short Description"
bottomRightLabel="Max 120" bottomRightLabel="Max 120"
bottomRightError={errors.subtitle === TOO_LONG}
onChange={handleChange} onChange={handleChange}
onBlur={handleBlur} onBlur={handleBlur}
value={values.subtitle || ''} value={values.subtitle || ''}
@ -294,6 +298,7 @@ const SubmissionSection = ({ classes, history }) => {
name="creator" name="creator"
label="Contact Person" label="Contact Person"
bottomLeftLabel="Name of the primary contact" bottomLeftLabel="Name of the primary contact"
errorBorder={touched.title && errors.creator === REQUIRED}
placeholder="Contract Person" placeholder="Contract Person"
onChange={handleChange} onChange={handleChange}
onBlur={handleBlur} onBlur={handleBlur}
@ -443,6 +448,7 @@ const SubmissionSection = ({ classes, history }) => {
label="Enter your funding goal" label="Enter your funding goal"
placeholder="Enter your funding goal" placeholder="Enter your funding goal"
bottomLeftLabel={usdValue} bottomLeftLabel={usdValue}
errorBorder={touched.goal && errors.goal === REQUIRED}
onChange={handleChange} onChange={handleChange}
onBlur={handleBlur} onBlur={handleBlur}
value={values.goal || ''} value={values.goal || ''}