react-validation icon indicating copy to clipboard operation
react-validation copied to clipboard

Module not found: Can't resolve 'validator' with version 3.0.7

Open aminacelik opened this issue 7 years ago • 2 comments

I get this error with [email protected]:

./src/utils/Validators.js
Module not found: Can't resolve 'validator' in '/Users/xxx/xxx/xxx/xxx/src/utils'

This is my ./src/utils/Validators.js file:

import React from 'react';
import validator from 'validator';
import ValidationErrorMsg from '../containers/ValidationErrorMsg';

export const required = (value) => {
  if (!value.toString().trim().length) {
    return (
    	<ValidationErrorMsg msg={'Required field.'} />
    );
  }
};

export const email = (value) => {
  if (!validator.isEmail(value)) {
    return "{ value } is not a valid email."
  }
};

export const password = (value, props, components) => {
	if (value !== components['confirm'][0].value) {
		return <span className="error">Passwords are not equal.</span>
	}
};

export const exactLength = (value, props) => {
  if (value.toString().trim().length !== props.exactLength) {
    return <span className="error">The value should be {props.exactLength} characters long.</span>
  }
}
```;

aminacelik avatar Jul 20 '18 07:07 aminacelik

validator is a separate npm package. If you want to use it, you have to install it: npm install validator.

cblaettl avatar Jul 26 '18 11:07 cblaettl

@aminacelik @cblaettl The solution is simple: in package.json move validator library from devDependencies to dependencies.

yhalapup avatar Jan 03 '20 14:01 yhalapup