Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 4f0ec9b

Browse files
committed
final fix of custom validator. Removing supportive prop.
1 parent c036ddf commit 4f0ec9b

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

src/components/FormField/index.jsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const FormField = ({ field, isGroupField }) => {
3535
placeholder={field.placeholder}
3636
value={input.value ?? ""}
3737
type="text"
38-
className={meta.error && (meta.touched || field.showError) ? "error" : ""}
38+
className={meta.error && meta.touched ? "error" : ""}
3939
readonly={field.readonly}
4040
onChange={input.onChange}
4141
onBlur={input.onBlur}
@@ -51,7 +51,7 @@ const FormField = ({ field, isGroupField }) => {
5151
onChange={input.onChange}
5252
onBlur={input.onBlur}
5353
onFocus={input.onFocus}
54-
className={meta.error && (meta.touched || field.showError) ? "error" : ""}
54+
className={meta.error && meta.touched ? "error" : ""}
5555
/>
5656
)}
5757
{field.type === FORM_FIELD_TYPE.TEXTAREA && (
@@ -61,7 +61,7 @@ const FormField = ({ field, isGroupField }) => {
6161
onChange={input.onChange}
6262
onBlur={input.onBlur}
6363
onFocus={input.onFocus}
64-
className={meta.error && (meta.touched || field.showError) ? "error" : ""}
64+
className={meta.error && meta.touched ? "error" : ""}
6565
/>
6666
)}
6767
{field.type === FORM_FIELD_TYPE.DATE && (
@@ -71,7 +71,7 @@ const FormField = ({ field, isGroupField }) => {
7171
onChange={input.onChange}
7272
onBlur={input.onBlur}
7373
onFocus={input.onFocus}
74-
className={meta.error && (meta.touched || field.showError) ? "error" : ""}
74+
className={meta.error && meta.touched ? "error" : ""}
7575
/>
7676
)}
7777
{field.type === FORM_FIELD_TYPE.SELECT && (
@@ -84,7 +84,7 @@ const FormField = ({ field, isGroupField }) => {
8484
onFocus={input.onFocus}
8585
/>
8686
)}
87-
{(field.isRequired || field.customValidator) && meta.error && (meta.touched || field.showError) && (
87+
{(field.isRequired || field.customValidator) && meta.error && meta.touched && (
8888
<div styleName="field-error">{meta.error}</div>
8989
)}
9090
</div>
@@ -112,7 +112,6 @@ FormField.prototype = {
112112
maxLength: PT.number,
113113
styleName: PT.string,
114114
readonly: PT.string,
115-
showError: PT.bool
116115
})
117116
).isRequired,
118117
isGroupField: PT.bool,

src/components/TCForm/index.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ TCForm.propTypes = {
120120
maxLength: PT.number,
121121
styleName: PT.string,
122122
readonly: PT.string,
123-
showError: PT.bool
124123
})
125124
).isRequired,
126125
onSubmit: PT.func,

src/routes/ResourceBookingForm/utils.js

-4
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@ export const getEditResourceBookingConfig = (onSubmit) => {
5252
const startDate = values[field.name];
5353
const endDate = values['endDate'];
5454
if(startDate && endDate && moment(endDate).startOf('day').isBefore(moment(startDate).startOf('day'))){
55-
endDateField.showError = true;
5655
return 'Start Date should not be after End Date';
5756
}
58-
endDateField.showError = false;
5957
return null;
6058
}
6159
},
@@ -69,10 +67,8 @@ export const getEditResourceBookingConfig = (onSubmit) => {
6967
const endDate = values[field.name];
7068
const startDate = values['startDate'];
7169
if(startDate && endDate && moment(endDate).startOf('day').isBefore(moment(startDate).startOf('day'))){
72-
startDateField.showError = true;
7370
return 'End Date should not be before Start Date';
7471
}
75-
startDateField.showError = false;
7672
return null;
7773
}
7874
},

0 commit comments

Comments
 (0)