Skip to content

Commit 68537d9

Browse files
committed
add less than and greater than variable validation
1 parent 4212d2b commit 68537d9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/components/Validations/options.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const VALIDATIONS = {
88
'unique',
99
'differentFrom',
1010
'sameAs',
11+
'lessThanVariable',
12+
'greaterThanVariable',
1113
],
1214
number: [
1315
'required',
@@ -16,18 +18,24 @@ const VALIDATIONS = {
1618
'unique',
1719
'differentFrom',
1820
'sameAs',
21+
'lessThanVariable',
22+
'greaterThanVariable',
1923
],
2024
datetime: [
2125
'required',
2226
'unique',
2327
'differentFrom',
2428
'sameAs',
29+
'lessThanVariable',
30+
'greaterThanVariable',
2531
],
2632
scalar: [
2733
'required',
2834
'unique',
2935
'differentFrom',
3036
'sameAs',
37+
'lessThanVariable',
38+
'greaterThanVariable',
3139
],
3240
boolean: [
3341
'required',
@@ -40,6 +48,8 @@ const VALIDATIONS = {
4048
'unique',
4149
'differentFrom',
4250
'sameAs',
51+
'lessThanVariable',
52+
'greaterThanVariable',
4353
],
4454
categorical: [
4555
'required',
@@ -63,6 +73,8 @@ const VALIDATIONS_WITH_NUMBER_VALUES = [
6373
const VALIDATIONS_WITH_LIST_VALUES = [
6474
'differentFrom',
6575
'sameAs',
76+
'lessThanVariable',
77+
'greaterThanVariable',
6678
];
6779

6880
const isValidationWithNumberValue = (validation) => (

src/components/sections/ValidationSection.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import { useSelector, useDispatch } from 'react-redux';
44
import { change, formValueSelector } from 'redux-form';
5+
import { get, filter } from 'lodash';
56
import { Section, Row } from '@components/EditorLayout';
67
import Validations from '@components/Validations';
78
import { getFieldId } from '../../utils/issues';
@@ -24,6 +25,7 @@ const ValidationSection = ({
2425
return true;
2526
};
2627

28+
const existingVariablesForType = filter(existingVariables, (variable) => get(variable, 'type') === variableType);
2729
return (
2830
<Section
2931
disabled={disabled}
@@ -43,7 +45,7 @@ const ValidationSection = ({
4345
form={form}
4446
name="validation"
4547
variableType={variableType}
46-
existingVariables={existingVariables}
48+
existingVariables={existingVariablesForType}
4749
/>
4850
</Row>
4951
</Section>

0 commit comments

Comments
 (0)