npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-nebo15-validate

v0.1.16

Published

React validation module by Nebo15

Readme

React Nebo15 Validate

Build Status

Validation module for React JS application.

Installation

npm install react-nebo15-validate --save

Usage

import React from 'react';
import validate from 'react-nebo15-validate';

const validationSchema = {
  first_name: {
    required: true,
    minLength: 4,
  },
  last_name: {
    require: true,
    minLength: 4,
  },
  second_name: {
    minLength: 2,
  },
  birthDate: {
    required: true,
    minDate: new Date(1930, 2, 12),
    maxDate: new Date(),
  },
};

const data = {
  first_name: 'John',
  last_name: '',
  birthDate: new Date(1920, 3, 24),
};

const result = validate(data, schema);

React Components

import React from 'react';
import { reduxFormValidate, ErrorMessages, ErrorMessage } from 'react-nebo15-validate';
import { reduxForm, Field } from 'redux-form';

class Input extends React.Component {
  render() {
    const { input, meta, label, ...rest } = this.props;
    return (
      <label>
        <span>{ label }</span>
        <br/>
        <input type="text" {...input} {...rest} />
        <br>
        <span>
          <ErrorMessages error={meta.error}>
            <ErrorMessage when="required">Custom required message</ErrorMessage>
          </ErrorMessages>
        </span>
      </label>
    );
  }
}

@reduxForm({
  form: 'profile',
  validate: reduxValidation({
    first_name: {
      required: true,
      minLength: 4,
    },
    last_name: {
      required: true,
      minLength: 4,
    },
    birth_date: {
      required: true
      maxDate: new Date(),
    },
  });
})
export default class ProfileForm extends React.Component {
  render() {
    const { handleSubmit } = this.props;
    return (
      <form onSubmit={handleSubmit}>
        <Field render={Input} name="first_name" label="First name" />
        <Field render={Input} name="last_name" label="Last name" />
        <Field render={Input} name="birth_date" type="date" label="Birth date" />
        <br/>
        <button type="submit">Submit</button>
      </form>
    );
  }
}

Validators

  • array - value is array
  • object - value is object
  • integer - value is integer
  • float - value is float number
  • numeric - value is number
  • boolean - value is boolean
  • string - value is string
  • required - value is required
  • ipv4 - value is valid IPV4
  • cardType - card provider (support visa, mastercard, accept array of types)
  • greaterThan - value > param
  • min - value >= param
  • max - value <= param
  • equals - value === param
  • length - value length equals param
  • minLength - value length greater or equal than param
  • maxLength - value length less or equal than param
  • minDate - value is after or the same as param
  • maxDate - value is before or the same as param
  • format - value should match regular expression in param
  • cast - value has type in param (av. array, map, object, integer, float, boolean, string)
  • inclusion - value is in array in param
  • exclusion - value is not one of value in array in param
  • subset - value is an array and it is a subset of array in param
  • number - value is a number and it is more than param.min and less than param.max
  • confirmation - value is equal the value by path in param. (eg. passwordConfirmation: { confirmation: 'password' })
  • acceptance - value is true
  • email - value is a valid email
  • phone_number - value is a valid phone number
  • card_number - value is a valid card number
  • unique - value is an array ant it has only unique values
  • dependency - expect existing value by path in param
  • alphanumeric - value is an alphanumeric string
  • metadata - description http://docs.apimanifest.apiary.io/#introduction/interacting-with-api/errors
  • json - value is a valid json object

Add custom validation

addValidation(name, validationFn) - add custom validation function
removeValidation(name) - remove custom validation function by name
getValidation(name) - get custom validation function by name

Redux Form

reduxFormValidate transforms error message for redux-form format.

Collections and arrays

You can validate collections and arrays.

import { collectionOf, arrayOf } from 'redux-nebo15-validate';

/// collectionOf

const schema = {
  contacts: collectionOf({
    first_name: {
      required: true,
      minLength: 4,
    },
    last_name: {
      required: true,
      minLength: 4,
    },
    second_name: {
      minLength: 4,
    }
  }),
}

const data = {
  contacts: [
    {
      first_name: 'Ivan',   // valid
      last_name: 'Ivanov',  // valid
      second_name: 'S'      // invalid
    }
  ]
}

// arrayOf

const schema = {
  tags: arrayOf({
    required: true,
    minLength: 4,
  }),
}

const data = {
  tags: ['new','news','tags'] // invalid, valid, valid
}