Skip to content

Commit 2190f9b

Browse files
committed
Fix react es6 00 sample
1 parent c5d2fd6 commit 2190f9b

2 files changed

Lines changed: 8 additions & 12 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ customerFormValidation
4343
console.log(validationResult.success); // true
4444
console.log(validationResult.formGlobalErrors); // []
4545
console.log(validationResult.fieldErrors);
46-
/*[
47-
{ succeeded: true, type: "REQUIRED", key: "firstName", errorMessage: "" },
48-
{ succeeded: true, type: "REQUIRED", key: "lastName", errorMessage: "" }
49-
]*/
46+
/*{
47+
firstName: { succeeded: true, type: "REQUIRED", key: "firstName", errorMessage: "" },
48+
lastName: { succeeded: true, type: "REQUIRED", key: "lastName", errorMessage: "" }
49+
}*/
5050
})
5151
.catch((error) => {
5252
// handle unexpected errors
@@ -240,7 +240,7 @@ testFormValidation
240240
.then((validationResult) => {
241241
console.log(validationResult.succeeded); // true
242242
console.log(validationResult.formGlobalErrors) // []
243-
console.log(validationResult.fieldErrors); // []
243+
console.log(validationResult.fieldErrors); // {}
244244
})
245245
.catch((error) => {
246246
// handle unexpected errors

samples/react/es6/00 SimpleForm/src/reducers/customer.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,10 @@ function customerProcessUIInputCompleted(state, action) {
4343
}
4444

4545
function customerSaveCompleted(state, action) {
46-
const newCustomerErrors = { ...state.customerErrors };
47-
48-
action.formValidationResult.fieldErrors.forEach(fieldValidationResult => {
49-
newCustomerErrors[fieldValidationResult.key] = fieldValidationResult;
50-
});
51-
5246
return {
5347
...state,
54-
customerErrors: newCustomerErrors
48+
customerErrors: {
49+
...action.formValidationResult.fieldErrors,
50+
},
5551
};
5652
}

0 commit comments

Comments
 (0)