Created
December 17, 2017 17:39
-
-
Save syedsuhail/f022da37a923d5dbc7767de9196821b9 to your computer and use it in GitHub Desktop.
Validation based on value of another field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const greaterThanField = (fieldName) => (fieldValue,formData) => | |
fieldValue > formData[fieldName] ? undefined : `Value must be greater that ${fieldName}`; | |
/* Rest of the component */ | |
this.state = { | |
validation:{ | |
totalPrice: [greaterThanField("price")] | |
} | |
} | |
/* Rest of the component */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment