0.4.11 • Published 6 years ago

interbit-validate v0.4.11

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

interbit-validate

Lightweight and flexible validation library for validating action creators and action payloads within covenants.

const {
  validate,
  objectValidationRules: { required, faIconPattern, chainIdPattern }
} = require('@btlgroup/interbit-validate')

const actionTypes = {
  UPDATE_PROJECT: 'project/UPDATE_PROJECT',
  REGISTER_PROJECT: 'project/REGISTER_PROJECT'
}

const actionCreators = {
  updateProject: ({ projectName, description, icon, launchUrl }) => ({
    type: actionTypes.UPDATE_PROJECT,
    payload: validate(
      { projectName, description, icon, launchUrl },        // Object to validate
      { projectName: required(), icon: faIconPattern() }    // Validation rules attached to properties
    )
  }),

  registerProject: ({ parentChainId }) => ({
    type: actionTypes.REGISTER_PROJECT,
    payload: validate(
      { parentChainId },                       // Object to validate
      { parentChainId: chainIdPattern() }      // Validation rules attached to properties
    )
  })
}
0.4.11

6 years ago

0.4.10

6 years ago

0.4.9

6 years ago

0.4.8

6 years ago

0.4.7

6 years ago

0.4.6

6 years ago

0.4.5

6 years ago

0.4.4

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.9

6 years ago

0.3.8

6 years ago

0.3.7

6 years ago

0.3.6

6 years ago