Make Validation

Make Validation

  • Docs
  • Help
  • Blog

›API

Getting Started

  • Introduction
  • Installation

API

  • Array API
  • Enum API
  • String API

Example

  • ExpressJS Example

Useful Links

  • Youtube Videos

Enum

Enum validation can be done with the following options

Options

  • options.enum (default {}, required: yes) It can be of 2 types string and object.
checks: {
  userType1: { type: types.enum, options: { enum: 'admin user' } },
  userType2: {
    type: types.enum,
    options: {
      enum: { 0: 'admin', 1: 'user' },
    },
  },
}
  • If options.enum a string the enum is seperated by space.
  • If options.enum an object the enum are the values in the objects.

Example

const result = makeValidation((types) => {
  return {
    payload: {
      type1: 'eagle', // invalid
      type2: 'admin', // valid
      type3: 'elephant', // invalid
      type4: 'user', // valid
    },
    checks: {
      type1: { type: types.enum, options: { enum: 'admin user' } },
      type2: { type: types.enum, options: { enum: 'admin user' } },
      type3: {
        type: types.enum,
        options: {
          enum: { 0: 'admin', 1: 'user' },
        },
      },
      type4: {
        type: types.enum,
        options: {
          enum: { 0: 'admin', 1: 'user' },
        },
      },
    },
  };
});
← Array APIString API →
  • Options
  • Example
Make Validation
Docs
Getting StartedAPI ReferenceExamples
Community
User ShowcaseStack OverflowTwitter
More
BlogGitHub
Copyright © 2020 Adeel Imran