Add lenght requirements for safe/owner naming when creating or loading a safe (#1357)

This commit is contained in:
Daniel Sanchez 2020-09-14 20:52:17 +02:00 committed by GitHub
parent f1916e92f1
commit 0d7fc80924
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 8 deletions

View File

@ -10,7 +10,13 @@ import { StepperPageFormProps } from 'src/components/Stepper'
import AddressInput from 'src/components/forms/AddressInput'
import Field from 'src/components/forms/Field'
import TextField from 'src/components/forms/TextField'
import { mustBeEthereumAddress, noErrorsOn, required } from 'src/components/forms/validator'
import {
mustBeEthereumAddress,
noErrorsOn,
required,
composeValidators,
minMaxLength,
} from 'src/components/forms/validator'
import Block from 'src/components/layout/Block'
import Col from 'src/components/layout/Col'
import Paragraph from 'src/components/layout/Paragraph'
@ -109,7 +115,7 @@ const DetailsForm = ({ errors, form }: DetailsFormProps): React.ReactElement =>
placeholder="Name of the Safe"
text="Safe name"
type="text"
validate={required}
validate={composeValidators(required, minMaxLength(1, 50))}
testId="load-safe-name-field"
/>
</Col>

View File

@ -8,7 +8,7 @@ import Identicon from 'src/components/Identicon'
import OpenPaper from 'src/components/Stepper/OpenPaper'
import Field from 'src/components/forms/Field'
import TextField from 'src/components/forms/TextField'
import { required } from 'src/components/forms/validator'
import { composeValidators, minMaxLength, required } from 'src/components/forms/validator'
import Block from 'src/components/layout/Block'
import Col from 'src/components/layout/Col'
import Hairline from 'src/components/layout/Hairline'
@ -132,7 +132,7 @@ const OwnerListComponent = (props) => {
placeholder="Owner Name*"
text="Owner Name"
type="text"
validate={required}
validate={composeValidators(required, minMaxLength(1, 50))}
testId={`load-safe-owner-name-${index}`}
/>
</Col>

View File

@ -4,7 +4,7 @@ import * as React from 'react'
import OpenPaper from 'src/components/Stepper/OpenPaper'
import Field from 'src/components/forms/Field'
import TextField from 'src/components/forms/TextField'
import { required } from 'src/components/forms/validator'
import { composeValidators, minMaxLength, required } from 'src/components/forms/validator'
import Block from 'src/components/layout/Block'
import Paragraph from 'src/components/layout/Paragraph'
import { FIELD_NAME } from 'src/routes/open/components/fields'
@ -44,7 +44,7 @@ const SafeName = ({ classes, safeName }) => (
placeholder="Name of the new Safe"
text="Safe name"
type="text"
validate={required}
validate={composeValidators(required, minMaxLength(1, 50))}
testId="create-safe-name-field"
/>
</Block>

View File

@ -16,7 +16,14 @@ import AddressInput from 'src/components/forms/AddressInput'
import Field from 'src/components/forms/Field'
import SelectField from 'src/components/forms/SelectField'
import TextField from 'src/components/forms/TextField'
import { composeValidators, minValue, mustBeInteger, noErrorsOn, required } from 'src/components/forms/validator'
import {
composeValidators,
minValue,
mustBeInteger,
noErrorsOn,
required,
minMaxLength,
} from 'src/components/forms/validator'
import Block from 'src/components/layout/Block'
import Button from 'src/components/layout/Button'
import Col from 'src/components/layout/Col'
@ -129,7 +136,7 @@ const SafeOwners = (props) => {
placeholder="Owner Name*"
text="Owner Name"
type="text"
validate={required}
validate={composeValidators(required, minMaxLength(1, 50))}
testId={`create-safe-owner-name-field-${index}`}
/>
</Col>