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'),
|
.required('The API key is required'),
|
||||||
privateKey: Yup.string('The private key must be a string')
|
privateKey: Yup.string('The private key must be a string')
|
||||||
.max(100, 'The private key is too long')
|
.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')
|
clientId: Yup.string('The client ID must be a string')
|
||||||
.max(100, 'The client ID is too long')
|
.max(100, 'The client ID is too long')
|
||||||
.required('The client ID is required'),
|
.required('The client ID is required'),
|
||||||
key: Yup.string('The key must be a string')
|
key: Yup.string('The API key must be a string')
|
||||||
.max(100, 'The key is too long')
|
.max(100, 'The API key is too long')
|
||||||
.required('The key is required'),
|
.required('The API key is required'),
|
||||||
secret: Yup.string('The secret must be a string')
|
secret: Yup.string('The API secret must be a string')
|
||||||
.max(100, 'The secret is too long')
|
.max(100, 'The API secret is too long')
|
||||||
.test(secretTest(account?.secret))
|
.test(secretTest(account?.secret, 'API secret'))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ export default {
|
||||||
.required('The API key is required'),
|
.required('The API key is required'),
|
||||||
privateKey: Yup.string('The private key must be a string')
|
privateKey: Yup.string('The private key must be a string')
|
||||||
.max(100, 'The private key is too long')
|
.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({
|
return Yup.object().shape({
|
||||||
authorizationValue: Yup.string('The authorization value must be a string')
|
authorizationValue: Yup.string('The authorization value must be a string')
|
||||||
.max(100, 'Too long')
|
.max(100, 'Too long')
|
||||||
.test(secretTest(account?.authorizationValue)),
|
.test(secretTest(account?.authorizationValue, 'authorization value')),
|
||||||
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 score threshold must be between 1 and 10')
|
.min(1, 'The score threshold must be between 1 and 10')
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ export default {
|
||||||
.required('The API key is required'),
|
.required('The API key is required'),
|
||||||
privateKey: Yup.string('The private key must be a string')
|
privateKey: Yup.string('The private key must be a string')
|
||||||
.max(100, 'The private key is too long')
|
.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'
|
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) {
|
test(val) {
|
||||||
if (R.isNil(secret) && R.isNil(val)) {
|
if (R.isNil(secret) && R.isNil(val)) {
|
||||||
return this.createError()
|
return this.createError()
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,12 @@ export default {
|
||||||
],
|
],
|
||||||
getValidationSchema: account => {
|
getValidationSchema: account => {
|
||||||
return Yup.object().shape({
|
return Yup.object().shape({
|
||||||
apiKey: Yup.string('The API key must be a string')
|
apiKey: Yup.string('The project ID must be a string')
|
||||||
.max(100, 'The API key is too long')
|
.max(100, 'The project ID is too long')
|
||||||
.required('The API key is required'),
|
.required('The project ID is required'),
|
||||||
apiSecret: Yup.string('The API secret must be a string')
|
apiSecret: Yup.string('The project secret must be a string')
|
||||||
.max(100, 'The API secret is too long')
|
.max(100, 'The project secret is too long')
|
||||||
.test(secretTest(account?.apiSecret)),
|
.test(secretTest(account?.apiSecret, 'project secret')),
|
||||||
endpoint: Yup.string('The endpoint must be a string')
|
endpoint: Yup.string('The endpoint must be a string')
|
||||||
.max(100, 'The endpoint is too long')
|
.max(100, 'The endpoint is too long')
|
||||||
.required('The endpoint is required')
|
.required('The endpoint is required')
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ export default {
|
||||||
.required('The client key is required'),
|
.required('The client key is required'),
|
||||||
clientSecret: Yup.string('The client secret must be a string')
|
clientSecret: Yup.string('The client secret must be a string')
|
||||||
.max(100, 'The client secret is too long')
|
.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'),
|
.required('The API key is required'),
|
||||||
privateKey: Yup.string('The private key must be a string')
|
privateKey: Yup.string('The private key must be a string')
|
||||||
.max(100, 'The private key is too long')
|
.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'),
|
.required('The account SID is required'),
|
||||||
authToken: Yup.string('The auth token must be a string')
|
authToken: Yup.string('The auth token must be a string')
|
||||||
.max(100, 'The auth token is too long')
|
.max(100, 'The auth token is too long')
|
||||||
.test(secretTest(account?.authToken)),
|
.test(secretTest(account?.authToken, 'auth token')),
|
||||||
fromNumber: Yup.string('The from number must be a string')
|
fromNumber: Yup.string('The Twilio number must be a string')
|
||||||
.max(100, 'The from number is too long')
|
.max(100, 'The Twilio number is too long')
|
||||||
.required('The from number is required'),
|
.required('The Twilio number is required'),
|
||||||
toNumber: Yup.string('The to number must be a string')
|
toNumber: Yup.string('The notifications number must be a string')
|
||||||
.max(100, 'The to number is too long')
|
.max(100, 'The notifications number is too long')
|
||||||
.required('The to number is required')
|
.required('The notifications number is required')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue