{"id":20816376,"url":"https://github.com/nebo15/react-nebo15-validate","last_synced_at":"2026-02-22T00:05:24.547Z","repository":{"id":57341800,"uuid":"87800493","full_name":"Nebo15/react-nebo15-validate","owner":"Nebo15","description":"Validation module for React application by Nebo15","archived":false,"fork":false,"pushed_at":"2018-10-11T10:09:41.000Z","size":87,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T13:51:40.170Z","etag":null,"topics":["javascript","nebo15","react","react-nebo15-validate","redux","redux-form","validate","validation","validator","webpack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nebo15.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-10T10:54:10.000Z","updated_at":"2018-10-11T10:09:40.000Z","dependencies_parsed_at":"2022-09-16T02:50:37.183Z","dependency_job_id":null,"html_url":"https://github.com/Nebo15/react-nebo15-validate","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nebo15%2Freact-nebo15-validate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nebo15%2Freact-nebo15-validate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nebo15%2Freact-nebo15-validate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nebo15%2Freact-nebo15-validate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nebo15","download_url":"https://codeload.github.com/Nebo15/react-nebo15-validate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252883387,"owners_count":21819169,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","nebo15","react","react-nebo15-validate","redux","redux-form","validate","validation","validator","webpack"],"created_at":"2024-11-17T21:33:30.541Z","updated_at":"2026-02-22T00:05:24.519Z","avatar_url":"https://github.com/Nebo15.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Nebo15 Validate\n\n[![Build Status](https://travis-ci.org/Nebo15/react-nebo15-validate.svg?branch=master)](https://travis-ci.org/Nebo15/react-nebo15-validate)\n\nValidation module for React JS application.\n\n### Installation\n\n```\nnpm install react-nebo15-validate --save\n```\n\n### Usage\n\n```\nimport React from 'react';\nimport validate from 'react-nebo15-validate';\n\nconst validationSchema = {\n  first_name: {\n    required: true,\n    minLength: 4,\n  },\n  last_name: {\n    require: true,\n    minLength: 4,\n  },\n  second_name: {\n    minLength: 2,\n  },\n  birthDate: {\n    required: true,\n    minDate: new Date(1930, 2, 12),\n    maxDate: new Date(),\n  },\n};\n\nconst data = {\n  first_name: 'John',\n  last_name: '',\n  birthDate: new Date(1920, 3, 24),\n};\n\nconst result = validate(data, schema);\n\n```\n\n#### React Components\n\n```\nimport React from 'react';\nimport { reduxFormValidate, ErrorMessages, ErrorMessage } from 'react-nebo15-validate';\nimport { reduxForm, Field } from 'redux-form';\n\nclass Input extends React.Component {\n  render() {\n    const { input, meta, label, ...rest } = this.props;\n    return (\n      \u003clabel\u003e\n        \u003cspan\u003e{ label }\u003c/span\u003e\n        \u003cbr/\u003e\n        \u003cinput type=\"text\" {...input} {...rest} /\u003e\n        \u003cbr\u003e\n        \u003cspan\u003e\n          \u003cErrorMessages error={meta.error}\u003e\n            \u003cErrorMessage when=\"required\"\u003eCustom required message\u003c/ErrorMessage\u003e\n          \u003c/ErrorMessages\u003e\n        \u003c/span\u003e\n      \u003c/label\u003e\n    );\n  }\n}\n\n@reduxForm({\n  form: 'profile',\n  validate: reduxValidation({\n    first_name: {\n      required: true,\n      minLength: 4,\n    },\n    last_name: {\n      required: true,\n      minLength: 4,\n    },\n    birth_date: {\n      required: true\n      maxDate: new Date(),\n    },\n  });\n})\nexport default class ProfileForm extends React.Component {\n  render() {\n    const { handleSubmit } = this.props;\n    return (\n      \u003cform onSubmit={handleSubmit}\u003e\n        \u003cField render={Input} name=\"first_name\" label=\"First name\" /\u003e\n        \u003cField render={Input} name=\"last_name\" label=\"Last name\" /\u003e\n        \u003cField render={Input} name=\"birth_date\" type=\"date\" label=\"Birth date\" /\u003e\n        \u003cbr/\u003e\n        \u003cbutton type=\"submit\"\u003eSubmit\u003c/button\u003e\n      \u003c/form\u003e\n    );\n  }\n}\n\n```\n\n### Validators\n\n- array - value is array\n- object - value is object\n- integer - value is integer\n- float - value is float number\n- numeric - value is number\n- boolean - value is boolean\n- string - value is string\n- required - value is required\n- ipv4 - value is valid IPV4\n- cardType - card provider (support visa, mastercard, accept array of types)\n- greaterThan -  value \u003e param\n- min - value \u003e= param\n- max - value \u003c= param\n- equals - value === param\n- length - value length equals param\n- minLength - value length greater or equal than param\n- maxLength - value length less or equal than param\n- minDate - value is after or the same as param\n- maxDate - value is before or the same as param\n- format - value should match regular expression in param\n- cast - value has type in param (av. array, map, object, integer, float, boolean, string)\n- inclusion - value is in array in param\n- exclusion - value is not one of value in array in param\n- subset - value is an array and it is a subset of array in param\n- number - value is a number and it is more than `param.min` and less than `param.max`\n- confirmation - value is equal the value by path in param. (eg. `passwordConfirmation: { confirmation: 'password' }`)\n- acceptance - value is true\n- email - value is a valid email\n- phone_number - value is a valid phone number\n- card_number - value is a valid card number\n- unique - value is an array ant it has only unique values\n- dependency - expect existing value by path in param\n- alphanumeric - value is an alphanumeric string\n- metadata - description http://docs.apimanifest.apiary.io/#introduction/interacting-with-api/errors\n- json - value is a valid json object\n\n### Add custom validation\n\n`addValidation(name, validationFn)` - add custom validation function       \n`removeValidation(name)` - remove custom validation function by name    \n`getValidation(name)` - get custom validation function by name    \n\n### Redux Form\n\n`reduxFormValidate` transforms error message for `redux-form` format.\n\n### Collections and arrays\n\nYou can validate collections and arrays.\n\n```\nimport { collectionOf, arrayOf } from 'redux-nebo15-validate';\n\n/// collectionOf\n\nconst schema = {\n  contacts: collectionOf({\n    first_name: {\n      required: true,\n      minLength: 4,\n    },\n    last_name: {\n      required: true,\n      minLength: 4,\n    },\n    second_name: {\n      minLength: 4,\n    }\n  }),\n}\n\nconst data = {\n  contacts: [\n    {\n      first_name: 'Ivan',   // valid\n      last_name: 'Ivanov',  // valid\n      second_name: 'S'      // invalid\n    }\n  ]\n}\n\n// arrayOf\n\nconst schema = {\n  tags: arrayOf({\n    required: true,\n    minLength: 4,\n  }),\n}\n\nconst data = {\n  tags: ['new','news','tags'] // invalid, valid, valid\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnebo15%2Freact-nebo15-validate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnebo15%2Freact-nebo15-validate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnebo15%2Freact-nebo15-validate/lists"}