1.0.0 • Published 6 years ago

@ncodefactory/prop-types-custom v1.0.0

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

prop-types-custom

quick and easy creation custom prop types validators for react props

installation:

npm:

npm install @ncodefactory/prop-types-custom --save

yarn:

yarn add @ncodefactory/prop-types-custom

usage:

import default_export_from_the_module_being_used from '@ncodefactory/prop-types-custom';

or

import { some_known_export_from_the_module_being_used } from '@ncodefactory/prop-types-custom';
const validator = value => value.length === 3;
const validatedTypeName = "threeCharString";
const threeCharStringPropType = customPropType(validatedTypeName, validator);

Component.propTypes = {
  name: threeCharStringPropType.isRequired,
  subName: threeCharStringPropType
};