Fixs composeValidators
Adds composeValidators for apps section
This commit is contained in:
parent
75418ebc52
commit
8da025c86e
|
@ -88,7 +88,10 @@ export const uniqueAddress = (addresses: string[] | List<string>) =>
|
||||||
return addressAlreadyExists ? ADDRESS_REPEATED_ERROR : undefined
|
return addressAlreadyExists ? ADDRESS_REPEATED_ERROR : undefined
|
||||||
})
|
})
|
||||||
|
|
||||||
export const composeValidators = (...validators: Function[]): FieldValidator => (value: Field, values, meta) => {
|
export const composeValidators = (...validators: Function[]): FieldValidator => (value: Field) =>
|
||||||
|
validators.reduce((error, validator) => error || validator(value), undefined)
|
||||||
|
|
||||||
|
export const composeValidatorsApps = (...validators: Function[]): FieldValidator => (value: Field, values, meta) => {
|
||||||
if (!meta.modified) {
|
if (!meta.modified) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { getAppInfoFromUrl } from './utils'
|
||||||
import Field from '~/components/forms/Field'
|
import Field from '~/components/forms/Field'
|
||||||
import DebounceValidationField from '~/components/forms/Field/DebounceValidationField'
|
import DebounceValidationField from '~/components/forms/Field/DebounceValidationField'
|
||||||
import GnoForm from '~/components/forms/GnoForm'
|
import GnoForm from '~/components/forms/GnoForm'
|
||||||
import { composeValidators, required } from '~/components/forms/validator'
|
import { composeValidatorsApps, required } from '~/components/forms/validator'
|
||||||
import Img from '~/components/layout/Img'
|
import Img from '~/components/layout/Img'
|
||||||
import appsIconSvg from '~/routes/safe/components/Transactions/TxsTable/TxType/assets/appsIcon.svg'
|
import appsIconSvg from '~/routes/safe/components/Transactions/TxsTable/TxType/assets/appsIcon.svg'
|
||||||
|
|
||||||
|
@ -120,7 +120,12 @@ const ManageApps = ({ appList, onAppAdded, onAppToggle }: Props) => {
|
||||||
name="appUrl"
|
name="appUrl"
|
||||||
placeholder="App URL"
|
placeholder="App URL"
|
||||||
type="text"
|
type="text"
|
||||||
validate={composeValidators(customRequiredValidator, urlValidator, uniqueAppValidator, safeAppValidator)}
|
validate={composeValidatorsApps(
|
||||||
|
customRequiredValidator,
|
||||||
|
urlValidator,
|
||||||
|
uniqueAppValidator,
|
||||||
|
safeAppValidator,
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<AppInfo>
|
<AppInfo>
|
||||||
|
|
Loading…
Reference in New Issue