Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make validate prop optional in Form #20526

Merged
merged 2 commits into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const propTypes = {
isSubmitButtonVisible: PropTypes.bool,

/** Callback to validate the form */
validate: PropTypes.func.isRequired,
validate: PropTypes.func,

/** Callback to submit the form */
onSubmit: PropTypes.func.isRequired,
Expand Down Expand Up @@ -85,6 +85,7 @@ const defaultProps = {
scrollContextEnabled: false,
footerContent: null,
style: [],
validate: () => ({}),
};

const Form = (props) => {
Expand Down
1 change: 0 additions & 1 deletion src/pages/ReportWelcomeMessagePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ function ReportWelcomeMessagePage(props) {
style={[styles.flexGrow1, styles.ph5]}
formID={ONYXKEYS.FORMS.WELCOME_MESSAGE_FORM}
onSubmit={submitForm}
validate={() => ({})}
submitButtonText={props.translate('common.save')}
enabledWhenOffline
>
Expand Down
1 change: 0 additions & 1 deletion src/pages/iou/MoneyRequestDescriptionPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class MoneyRequestDescriptionPage extends Component {
formID={ONYXKEYS.FORMS.MONEY_REQUEST_DESCRIPTION_FORM}
onSubmit={this.updateComment}
submitButtonText={this.props.translate('common.save')}
validate={() => ({})}
enabledWhenOffline
>
<View style={styles.mb4}>
Expand Down
10 changes: 0 additions & 10 deletions src/pages/tasks/NewTaskDescriptionPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ const defaultProps = {
const NewTaskDescriptionPage = (props) => {
const inputRef = useRef(null);

/**
* @param {Object} values - form input values passed by the Form component
* @returns {Object}
*/
function validate() {
// This field is optional and can be left blank, so we should not require validation for its value.
return {};
}

// On submit, we want to call the assignTask function and wait to validate
// the response
const onSubmit = (values) => {
Expand Down Expand Up @@ -79,7 +70,6 @@ const NewTaskDescriptionPage = (props) => {
submitButtonText={props.translate('common.next')}
style={[styles.mh5, styles.mt5, styles.flexGrow1]}
onSubmit={(values) => onSubmit(values)}
validate={() => validate()}
enabledWhenOffline
>
<View style={styles.mb5}>
Expand Down