Skip to content

Commit

Permalink
fix: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
tienifr committed Apr 3, 2023
1 parent 65b4986 commit e5aad43
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,23 +171,23 @@ class Form extends React.Component {
* @returns {Object} - An object containing the errors for each inputID, e.g. {inputID1: error1, inputID2: error2}
*/
validate(values) {
const trimmedValues = {};
const trimmedStringValues = {};
_.each(values, (inputValue, inputID) => {
if (_.isString(inputValue)) {
(trimmedValues[inputID] = inputValue.trim());
(trimmedStringValues[inputID] = inputValue.trim());
} else {
trimmedValues[inputID] = inputValue;
trimmedStringValues[inputID] = inputValue;
}
});

FormActions.setErrors(this.props.formID, null);
FormActions.setErrorFields(this.props.formID, null);

// Run any validations passed as a prop
const validationErrors = this.props.validate(trimmedValues);
const validationErrors = this.props.validate(trimmedStringValues);

// Validate the input for html tags. It should supercede any other error
_.each(trimmedValues, (inputValue, inputID) => {
_.each(trimmedStringValues, (inputValue, inputID) => {
// Return early if there is no value OR the value is not a string OR there are no HTML characters
if (!inputValue || !_.isString(inputValue) || inputValue.search(CONST.VALIDATE_FOR_HTML_TAG_REGEX) === -1) {
return;
Expand Down

0 comments on commit e5aad43

Please sign in to comment.