Merge pull request #1111 from chaotixkilla/feat-no-leading-zeros-test
Add no leading zeros test to 3rd party services form numeric values
This commit is contained in:
commit
1065f31e23
11 changed files with 30 additions and 16 deletions
|
|
@ -3,7 +3,7 @@ import * as Yup from 'yup'
|
||||||
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
||||||
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
||||||
|
|
||||||
import secretTest from './helper'
|
import { secretTest } from './helper'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
code: 'binanceus',
|
code: 'binanceus',
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import {
|
||||||
Autocomplete
|
Autocomplete
|
||||||
} from 'src/components/inputs/formik'
|
} from 'src/components/inputs/formik'
|
||||||
|
|
||||||
import secretTest from './helper'
|
import { secretTest } from './helper'
|
||||||
|
|
||||||
const isDefined = it => it && it.length
|
const isDefined = it => it && it.length
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import * as Yup from 'yup'
|
||||||
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
||||||
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
||||||
|
|
||||||
import secretTest from './helper'
|
import { secretTest } from './helper'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
code: 'bitstamp',
|
code: 'bitstamp',
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import * as Yup from 'yup'
|
||||||
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
||||||
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
||||||
|
|
||||||
import secretTest from './helper'
|
import { secretTest } from './helper'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
code: 'cex',
|
code: 'cex',
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import CheckboxFormik from 'src/components/inputs/formik/Checkbox'
|
||||||
import NumberInputFormik from 'src/components/inputs/formik/NumberInput'
|
import NumberInputFormik from 'src/components/inputs/formik/NumberInput'
|
||||||
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
||||||
|
|
||||||
import secretTest from './helper'
|
import { secretTest, leadingZerosTest } from './helper'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
code: 'ciphertrace',
|
code: 'ciphertrace',
|
||||||
|
|
@ -37,15 +37,19 @@ export default {
|
||||||
],
|
],
|
||||||
getValidationSchema: account => {
|
getValidationSchema: account => {
|
||||||
return Yup.object().shape({
|
return Yup.object().shape({
|
||||||
authorizationValue: Yup.string('The score threshold must be a string')
|
authorizationValue: Yup.string('The authorization value must be a string')
|
||||||
.required('The authorization value is required')
|
|
||||||
.max(100, 'Too long')
|
.max(100, 'Too long')
|
||||||
.test(secretTest(account?.authorizationValue)),
|
.test(secretTest(account?.authorizationValue)),
|
||||||
scoreThreshold: Yup.number('The score threshold must be a number')
|
scoreThreshold: Yup.number('The score threshold must be a number')
|
||||||
.required('A score threshold is required')
|
.required('A score threshold is required')
|
||||||
.min(1, 'The number should be between 1 and 10')
|
.min(1, 'The score threshold must be between 1 and 10')
|
||||||
.max(10, 'The number should be between 1 and 10')
|
.max(10, 'The score threshold must be between 1 and 10')
|
||||||
.test(secretTest(account?.scoreThreshold))
|
.integer('The score threshold must be an integer')
|
||||||
|
.test(
|
||||||
|
'no-leading-zeros',
|
||||||
|
'The score threshold must not have leading zeros',
|
||||||
|
leadingZerosTest
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import * as Yup from 'yup'
|
||||||
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
||||||
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
||||||
|
|
||||||
import secretTest from './helper'
|
import { secretTest } from './helper'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
code: 'ftx',
|
code: 'ftx',
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,14 @@ const secretTest = secret => ({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
export default secretTest
|
const leadingZerosTest = (value, context) => {
|
||||||
|
if (
|
||||||
|
R.startsWith('0', context.originalValue) &&
|
||||||
|
R.length(context.originalValue) > 1
|
||||||
|
) {
|
||||||
|
return context.createError()
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
export { secretTest, leadingZerosTest }
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import * as Yup from 'yup'
|
||||||
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
||||||
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
||||||
|
|
||||||
import secretTest from './helper'
|
import { secretTest } from './helper'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
code: 'infura',
|
code: 'infura',
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import * as Yup from 'yup'
|
||||||
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
||||||
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
||||||
|
|
||||||
import secretTest from './helper'
|
import { secretTest } from './helper'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
code: 'itbit',
|
code: 'itbit',
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import * as Yup from 'yup'
|
||||||
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
||||||
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
||||||
|
|
||||||
import secretTest from './helper'
|
import { secretTest } from './helper'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
code: 'kraken',
|
code: 'kraken',
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import * as Yup from 'yup'
|
||||||
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
||||||
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
||||||
|
|
||||||
import secretTest from './helper'
|
import { secretTest } from './helper'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
code: 'twilio',
|
code: 'twilio',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue