fix: validation errors
This commit is contained in:
parent
5cfa99945c
commit
2ab351a455
10 changed files with 28 additions and 26 deletions
|
|
@ -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'))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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'))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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'))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue