Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- src/
- --/views
- --validations.js
- --/users
- --UserCreate.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;
- 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>
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement