Skip to content

Latest commit

 

History

History
58 lines (42 loc) · 1.63 KB

File metadata and controls

58 lines (42 loc) · 1.63 KB

Documentation

Getting Started

Usage

import Validator from '@syncano/validate'

const validator = new Validator({args, meta, config})

Installation

Installing from NPM

npm i @syncano/validate --save

Methods

Name Description
validator.validateRequest Validate incoming parameters
validator.validateResponse Validate endpoint response

validator.validateRequest(ctx)

Type Name Default Description
object ctx {} Object containing args, meta and config
export default ctx => {
  validator.validateRequest(ctx)
}

validator.validateResponse(responseType, response)

Type Name Default Description
string responseType Name of response defined in syncano.yml
mixed response Endpoint response
export default ctx => {
  validator.validateResponse('success', {
    messsage: 'Action was successful'
  })
}