Skip to content

mkamakura/redux-validation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

redux-validation

validate for action property

Installation

npm install --save redux-validation

Usage

  • applyMiddleware
import { createStore, applyMiddleware } from 'redux';
import reducer from './modules/reducer';
import createLogger from 'redux-logger';
import validationMiddleware from 'redux-validation';

export default function() {
  const createStoreWithMiddleware = applyMiddleware(validationMiddleware, createLogger())(createStore);
  return createStoreWithMiddleware(reducer);
}
export const sample = createAction(ACTION_TYPE, (payload) => paylaod, () => ({
  validation: {
    name: [   // input name
     {
        func: (payload) => payload.length > 0, // validation
        msg: 'Name must be Required.', // invalid message
      },
    ],
  },
});
export default handleActions({
  [ACTION_TYPE]: (state, { payload: { data, validation } }) => ({
    ...state,
    name: data,
    validation,
  }),
}, {});

About

validate for action property

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published