diff --git a/src/components/Validations/options.js b/src/components/Validations/options.js index 4af3389cf..c5843a88b 100644 --- a/src/components/Validations/options.js +++ b/src/components/Validations/options.js @@ -8,6 +8,8 @@ const VALIDATIONS = { 'unique', 'differentFrom', 'sameAs', + 'lessThanVariable', + 'greaterThanVariable', ], number: [ 'required', @@ -16,18 +18,24 @@ const VALIDATIONS = { 'unique', 'differentFrom', 'sameAs', + 'lessThanVariable', + 'greaterThanVariable', ], datetime: [ 'required', 'unique', 'differentFrom', 'sameAs', + 'lessThanVariable', + 'greaterThanVariable', ], scalar: [ 'required', 'unique', 'differentFrom', 'sameAs', + 'lessThanVariable', + 'greaterThanVariable', ], boolean: [ 'required', @@ -40,6 +48,8 @@ const VALIDATIONS = { 'unique', 'differentFrom', 'sameAs', + 'lessThanVariable', + 'greaterThanVariable', ], categorical: [ 'required', @@ -63,6 +73,8 @@ const VALIDATIONS_WITH_NUMBER_VALUES = [ const VALIDATIONS_WITH_LIST_VALUES = [ 'differentFrom', 'sameAs', + 'lessThanVariable', + 'greaterThanVariable', ]; const isValidationWithNumberValue = (validation) => ( diff --git a/src/components/sections/ValidationSection.js b/src/components/sections/ValidationSection.js index e77401f49..add63a2e9 100644 --- a/src/components/sections/ValidationSection.js +++ b/src/components/sections/ValidationSection.js @@ -2,6 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { useSelector, useDispatch } from 'react-redux'; import { change, formValueSelector } from 'redux-form'; +import { get, filter } from 'lodash'; import { Section, Row } from '@components/EditorLayout'; import Validations from '@components/Validations'; import { getFieldId } from '../../utils/issues'; @@ -24,6 +25,7 @@ const ValidationSection = ({ return true; }; + const existingVariablesForType = filter(existingVariables, (variable) => get(variable, 'type') === variableType); return (