fix(striker-ui): re-add not-blank tests to test batch builders

main
Tsu-ba-me 2 years ago
parent d8c6c2bec9
commit 0bdc5dd44e
  1. 4
      striker-ui/lib/test_input/buildDomainTestBatch.tsx
  2. 7
      striker-ui/lib/test_input/buildIPAddressTestBatch.tsx
  3. 10
      striker-ui/lib/test_input/buildIpCsvTestBatch.tsx
  4. 8
      striker-ui/lib/test_input/buildPeacefulStringTestBatch.tsx
  5. 7
      striker-ui/lib/test_input/buildUUIDTestBatch.tsx

@ -1,5 +1,6 @@
import { REP_DOMAIN } from '../consts/REG_EXP_PATTERNS'; import { REP_DOMAIN } from '../consts/REG_EXP_PATTERNS';
import testNotBlank from './testNotBlank';
import { InlineMonoText } from '../../components/Text'; import { InlineMonoText } from '../../components/Text';
const buildDomainTestBatch: BuildInputTestBatchFunction = ( const buildDomainTestBatch: BuildInputTestBatchFunction = (
@ -12,6 +13,9 @@ const buildDomainTestBatch: BuildInputTestBatchFunction = (
isRequired, isRequired,
onFinishBatch, onFinishBatch,
tests: [ tests: [
{
test: testNotBlank,
},
{ {
onFailure: (...args) => { onFailure: (...args) => {
onDomainTestFailure( onDomainTestFailure(

@ -1,5 +1,7 @@
import { REP_IPV4 } from '../consts/REG_EXP_PATTERNS'; import { REP_IPV4 } from '../consts/REG_EXP_PATTERNS';
import testNotBlank from './testNotBlank';
const buildIPAddressTestBatch: BuildInputTestBatchFunction = ( const buildIPAddressTestBatch: BuildInputTestBatchFunction = (
inputName, inputName,
onSuccess, onSuccess,
@ -10,10 +12,13 @@ const buildIPAddressTestBatch: BuildInputTestBatchFunction = (
isRequired, isRequired,
onFinishBatch, onFinishBatch,
tests: [ tests: [
{
test: testNotBlank,
},
{ {
onFailure: (...args) => { onFailure: (...args) => {
onIPv4TestFailure( onIPv4TestFailure(
`${inputName} should be a valid IPv4 address.`, <>{inputName} should be a valid IPv4 address.</>,
...args, ...args,
); );
}, },

@ -1,5 +1,7 @@
import { REP_IPV4_CSV } from '../consts/REG_EXP_PATTERNS'; import { REP_IPV4_CSV } from '../consts/REG_EXP_PATTERNS';
import testNotBlank from './testNotBlank';
const buildIpCsvTestBatch: BuildInputTestBatchFunction = ( const buildIpCsvTestBatch: BuildInputTestBatchFunction = (
inputName, inputName,
onSuccess, onSuccess,
@ -10,10 +12,16 @@ const buildIpCsvTestBatch: BuildInputTestBatchFunction = (
isRequired, isRequired,
onFinishBatch, onFinishBatch,
tests: [ tests: [
{
test: testNotBlank,
},
{ {
onFailure: (...args) => { onFailure: (...args) => {
onIpCsvTestFailure( onIpCsvTestFailure(
`${inputName} must be one or more valid IPv4 addresses separated by comma; without trailing comma.`, <>
{inputName} must be one or more valid IPv4 addresses separated by
comma(s); without trailing comma.
</>,
...args, ...args,
); );
}, },

@ -1,5 +1,6 @@
import { REP_PEACEFUL_STRING } from '../consts/REG_EXP_PATTERNS'; import { REP_PEACEFUL_STRING } from '../consts/REG_EXP_PATTERNS';
import testNotBlank from './testNotBlank';
import { InlineMonoText } from '../../components/Text'; import { InlineMonoText } from '../../components/Text';
const buildPeacefulStringTestBatch: BuildInputTestBatchFunction = ( const buildPeacefulStringTestBatch: BuildInputTestBatchFunction = (
@ -12,6 +13,13 @@ const buildPeacefulStringTestBatch: BuildInputTestBatchFunction = (
isRequired, isRequired,
onFinishBatch, onFinishBatch,
tests: [ tests: [
{
/**
* Not-blank test ensures no unnecessary error message is provided when
* input is not (yet) filled.
*/
test: testNotBlank,
},
{ {
onFailure: (...args) => { onFailure: (...args) => {
onTestPeacefulStringFailureAppend( onTestPeacefulStringFailureAppend(

@ -1,5 +1,7 @@
import { REP_UUID } from '../consts/REG_EXP_PATTERNS'; import { REP_UUID } from '../consts/REG_EXP_PATTERNS';
import testNotBlank from './testNotBlank';
const buildUUIDTestBatch: BuildInputTestBatchFunction = ( const buildUUIDTestBatch: BuildInputTestBatchFunction = (
inputName, inputName,
onSuccess, onSuccess,
@ -10,9 +12,12 @@ const buildUUIDTestBatch: BuildInputTestBatchFunction = (
isRequired, isRequired,
onFinishBatch, onFinishBatch,
tests: [ tests: [
{
test: testNotBlank,
},
{ {
onFailure: (...args) => { onFailure: (...args) => {
onUUIDTestFailure(`${inputName} must be a valid UUID.`, ...args); onUUIDTestFailure(<>{inputName} must be a valid UUID.</>, ...args);
}, },
test: ({ value }) => REP_UUID.test(value as string), test: ({ value }) => REP_UUID.test(value as string),
}, },

Loading…
Cancel
Save