verificator
Version:
Client and server-side validation JavaScript library
16 lines (15 loc) • 538 B
JavaScript
import { START_VALIDATE, STOP_VALIDATE } from '../constants/types';
const initialState = {};
const reducer = (state = initialState, action) => {
const { type } = action;
if (type === START_VALIDATE) {
const attribute = action.payload.attribute;
return Object.assign({}, state, { [attribute]: true });
}
else if (type === STOP_VALIDATE) {
const attribute = action.payload.attribute;
return Object.assign({}, state, { [attribute]: false });
}
return state;
};
export default reducer;