Skip to content

Instantly share code, notes, and snippets.

@jackcallister
Created September 22, 2015 08:06
Show Gist options
  • Save jackcallister/c0bde27d42b2e05a1fb1 to your computer and use it in GitHub Desktop.
Save jackcallister/c0bde27d42b2e05a1fb1 to your computer and use it in GitHub Desktop.
Validation Pattern
export function mapPersonStateToProps(store) {
const validationErrors = personValidator(store.person.editableResource)
return {
validationErrors: validationErrors,
...restOfPropsFromStore
}
}
export function updatePersonProp(propName, propValue) {
return {
type: UPDATE_PERSON_PROP,
payload: {propName, propValue}
}
}
...
export const initialState = {
loading: true,
resource: {},
editableResource: {},
showSuccessMessage: false,
successMessage: 'Person updated successfully.',
error: false,
errorMessage: '',
updating: false
}
export default function person(state = initialState, action) {
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment