From 2ab351a45584ca23a403a6d0664c63944918d54a Mon Sep 17 00:00:00 2001 From: Nikola Ubavic <53820106+ubavic@users.noreply.github.com> Date: Mon, 14 Mar 2022 18:26:41 +0100 Subject: [PATCH] fix: validation errors --- .../src/pages/Services/schemas/binanceus.js | 2 +- .../src/pages/Services/schemas/bitstamp.js | 12 ++++++------ .../src/pages/Services/schemas/cex.js | 2 +- .../src/pages/Services/schemas/ciphertrace.js | 2 +- .../src/pages/Services/schemas/ftx.js | 2 +- .../src/pages/Services/schemas/helper.js | 4 +++- .../src/pages/Services/schemas/infura.js | 12 ++++++------ .../src/pages/Services/schemas/itbit.js | 2 +- .../src/pages/Services/schemas/kraken.js | 2 +- .../src/pages/Services/schemas/twilio.js | 14 +++++++------- 10 files changed, 28 insertions(+), 26 deletions(-) diff --git a/new-lamassu-admin/src/pages/Services/schemas/binanceus.js b/new-lamassu-admin/src/pages/Services/schemas/binanceus.js index 61090700..eee1ece7 100644 --- a/new-lamassu-admin/src/pages/Services/schemas/binanceus.js +++ b/new-lamassu-admin/src/pages/Services/schemas/binanceus.js @@ -30,7 +30,7 @@ export default { .required('The API key is required'), privateKey: Yup.string('The private key must be a string') .max(100, 'The private key is too long') - .test(secretTest(account?.privateKey)) + .test(secretTest(account?.privateKey, 'private key')) }) } } diff --git a/new-lamassu-admin/src/pages/Services/schemas/bitstamp.js b/new-lamassu-admin/src/pages/Services/schemas/bitstamp.js index 18676b29..df8e8105 100644 --- a/new-lamassu-admin/src/pages/Services/schemas/bitstamp.js +++ b/new-lamassu-admin/src/pages/Services/schemas/bitstamp.js @@ -35,12 +35,12 @@ export default { clientId: Yup.string('The client ID must be a string') .max(100, 'The client ID is too long') .required('The client ID is required'), - key: Yup.string('The key must be a string') - .max(100, 'The key is too long') - .required('The key is required'), - secret: Yup.string('The secret must be a string') - .max(100, 'The secret is too long') - .test(secretTest(account?.secret)) + key: Yup.string('The API key must be a string') + .max(100, 'The API key is too long') + .required('The API key is required'), + secret: Yup.string('The API secret must be a string') + .max(100, 'The API secret is too long') + .test(secretTest(account?.secret, 'API secret')) }) } } diff --git a/new-lamassu-admin/src/pages/Services/schemas/cex.js b/new-lamassu-admin/src/pages/Services/schemas/cex.js index e56d1f23..3cf69861 100644 --- a/new-lamassu-admin/src/pages/Services/schemas/cex.js +++ b/new-lamassu-admin/src/pages/Services/schemas/cex.js @@ -30,7 +30,7 @@ export default { .required('The API key is required'), privateKey: Yup.string('The private key must be a string') .max(100, 'The private key is too long') - .test(secretTest(account?.privateKey)) + .test(secretTest(account?.privateKey, 'private key')) }) } } diff --git a/new-lamassu-admin/src/pages/Services/schemas/ciphertrace.js b/new-lamassu-admin/src/pages/Services/schemas/ciphertrace.js index 65d02351..b090d8da 100644 --- a/new-lamassu-admin/src/pages/Services/schemas/ciphertrace.js +++ b/new-lamassu-admin/src/pages/Services/schemas/ciphertrace.js @@ -39,7 +39,7 @@ export default { return Yup.object().shape({ authorizationValue: Yup.string('The authorization value must be a string') .max(100, 'Too long') - .test(secretTest(account?.authorizationValue)), + .test(secretTest(account?.authorizationValue, 'authorization value')), scoreThreshold: Yup.number('The score threshold must be a number') .required('A score threshold is required') .min(1, 'The score threshold must be between 1 and 10') diff --git a/new-lamassu-admin/src/pages/Services/schemas/ftx.js b/new-lamassu-admin/src/pages/Services/schemas/ftx.js index 264ff801..bdb446ce 100644 --- a/new-lamassu-admin/src/pages/Services/schemas/ftx.js +++ b/new-lamassu-admin/src/pages/Services/schemas/ftx.js @@ -30,7 +30,7 @@ export default { .required('The API key is required'), privateKey: Yup.string('The private key must be a string') .max(100, 'The private key is too long') - .test(secretTest(account?.privateKey)) + .test(secretTest(account?.privateKey, 'private key')) }) } } diff --git a/new-lamassu-admin/src/pages/Services/schemas/helper.js b/new-lamassu-admin/src/pages/Services/schemas/helper.js index e1d1ff3f..ccb49a79 100644 --- a/new-lamassu-admin/src/pages/Services/schemas/helper.js +++ b/new-lamassu-admin/src/pages/Services/schemas/helper.js @@ -1,6 +1,8 @@ import * as R from 'ramda' -const secretTest = secret => ({ +const secretTest = (secret, message) => ({ + name: 'secret-test', + message: message ? `The ${message} is invalid` : 'Invalid field', test(val) { if (R.isNil(secret) && R.isNil(val)) { return this.createError() diff --git a/new-lamassu-admin/src/pages/Services/schemas/infura.js b/new-lamassu-admin/src/pages/Services/schemas/infura.js index ee9d0d84..aa026782 100644 --- a/new-lamassu-admin/src/pages/Services/schemas/infura.js +++ b/new-lamassu-admin/src/pages/Services/schemas/infura.js @@ -31,12 +31,12 @@ export default { ], getValidationSchema: account => { return Yup.object().shape({ - apiKey: Yup.string('The API key must be a string') - .max(100, 'The API key is too long') - .required('The API key is required'), - apiSecret: Yup.string('The API secret must be a string') - .max(100, 'The API secret is too long') - .test(secretTest(account?.apiSecret)), + apiKey: Yup.string('The project ID must be a string') + .max(100, 'The project ID is too long') + .required('The project ID is required'), + apiSecret: Yup.string('The project secret must be a string') + .max(100, 'The project secret is too long') + .test(secretTest(account?.apiSecret, 'project secret')), endpoint: Yup.string('The endpoint must be a string') .max(100, 'The endpoint is too long') .required('The endpoint is required') diff --git a/new-lamassu-admin/src/pages/Services/schemas/itbit.js b/new-lamassu-admin/src/pages/Services/schemas/itbit.js index dc9a9645..702ca29e 100644 --- a/new-lamassu-admin/src/pages/Services/schemas/itbit.js +++ b/new-lamassu-admin/src/pages/Services/schemas/itbit.js @@ -48,7 +48,7 @@ export default { .required('The client key is required'), clientSecret: Yup.string('The client secret must be a string') .max(100, 'The client secret is too long') - .test(secretTest(account?.clientSecret)) + .test(secretTest(account?.clientSecret, 'client secret')) }) } } diff --git a/new-lamassu-admin/src/pages/Services/schemas/kraken.js b/new-lamassu-admin/src/pages/Services/schemas/kraken.js index 6848b05d..752c3f7a 100644 --- a/new-lamassu-admin/src/pages/Services/schemas/kraken.js +++ b/new-lamassu-admin/src/pages/Services/schemas/kraken.js @@ -30,7 +30,7 @@ export default { .required('The API key is required'), privateKey: Yup.string('The private key must be a string') .max(100, 'The private key is too long') - .test(secretTest(account?.privateKey)) + .test(secretTest(account?.privateKey, 'private key')) }) } } diff --git a/new-lamassu-admin/src/pages/Services/schemas/twilio.js b/new-lamassu-admin/src/pages/Services/schemas/twilio.js index cf5a0174..1ed2228f 100644 --- a/new-lamassu-admin/src/pages/Services/schemas/twilio.js +++ b/new-lamassu-admin/src/pages/Services/schemas/twilio.js @@ -40,13 +40,13 @@ export default { .required('The account SID is required'), authToken: Yup.string('The auth token must be a string') .max(100, 'The auth token is too long') - .test(secretTest(account?.authToken)), - fromNumber: Yup.string('The from number must be a string') - .max(100, 'The from number is too long') - .required('The from number is required'), - toNumber: Yup.string('The to number must be a string') - .max(100, 'The to number is too long') - .required('The to number is required') + .test(secretTest(account?.authToken, 'auth token')), + fromNumber: Yup.string('The Twilio number must be a string') + .max(100, 'The Twilio number is too long') + .required('The Twilio number is required'), + toNumber: Yup.string('The notifications number must be a string') + .max(100, 'The notifications number is too long') + .required('The notifications number is required') }) } }