У меня есть приложение реагирования со следующим деревом:
src/
--/views
--validations.js
--/users
--UserCreate.js
Мой код validations.js:
import {
required,
minLength,
maxLength,
minValue,
maxValue,
number,
regex,
email,
choices
} from 'react-admin';
export const required = () => required("Campo obrigatório")
export const minLength = (value) => minLength(value,"Este campo deve ter o minimo de "+value+" caracteres")
export const maxLength = (value) => maxLength("Este campo deve ter o máximo de "+value+" caracteres")
export const email = () => email("Digite um e-mail válido")
export const passwordsMatch = (value, allValues) => value !== allValues.password ? 'As senhas não coincidem' : undefined;
Мой код UserCreate.js, подобный этому:
import React, { Component } from 'react';
import { Create, SimpleForm, TextInput, DisabledInput } from 'react-admin';
import { required, email, minLength,maxLength } from './../validations';
export const UserCreate = props => (
<Create {...props}>
<SimpleForm redirect="list">
<DisabledInput label="#" source="id" />
<TextInput source="name" validate={[required(),minLength(5),maxLength(20)]} label="Nome"/>
<TextInput source="email" validate={[required(),minLength(5),maxLength(20),email()]} label="E-mail"/>
<TextInput source="password" validate={[required(),minLength(8),maxLength(20)]} label="Senha" type="password"/>
<TextInput name="confirm_password" validate={[passwordsMatch]} label="Confirmar senha" type="password"/>
</SimpleForm>
</Create>
)
Но при запуске я получаю следующую ошибку:
./src/views/users/UserCreate.js
Attempted import error: 'email' is not exported from './../validations'.
что я делаю не так?