Prefinem/nativemodels

View on GitHub
src/customtypes/enumerable.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
const createType = require('./../createType');

const enumerable = (enumerableValues) =>
  createType({
    name: 'enumerable',
    validCheck: (key, value) => {
      if (enumerableValues.indexOf(value) > -1) {
        return true;
      }

      throw new Error(`NativeModels - Property ${key} is not in the list of enumerable values`);
    },
  });

module.exports = enumerable;