cc: Add ransomware directory path validation error messages

This commit is contained in:
Shreya 2021-07-01 13:22:09 +05:30
parent 73c61ebcf0
commit 8af93c4304
1 changed files with 7 additions and 1 deletions

View File

@ -1,4 +1,6 @@
import {IP, IP_RANGE} from './ValidationFormats'; import {IP, IP_RANGE, VALID_DIR_LINUX, VALID_DIR_WINDOWS} from './ValidationFormats';
let invalidDirMessage = 'Invalid directory. Path should be absolute or begin with an environment variable.';
export default function transformErrors(errors) { export default function transformErrors(errors) {
return errors.map(error => { return errors.map(error => {
@ -8,6 +10,10 @@ export default function transformErrors(errors) {
error.message = 'Invalid IP range, refer to description for valid examples.' error.message = 'Invalid IP range, refer to description for valid examples.'
} else if (error.name === 'format' && error.params.format === IP) { } else if (error.name === 'format' && error.params.format === IP) {
error.message = 'Invalid IP.' error.message = 'Invalid IP.'
} else if (error.name === 'format' && error.params.format === VALID_DIR_LINUX) {
error.message = invalidDirMessage
} else if (error.name === 'format' && error.params.format === VALID_DIR_WINDOWS) {
error.message = invalidDirMessage
} }
return error; return error;
}); });