Skip to content

Commit

Permalink
add less than and greater than variable validation
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccamadsen committed Apr 29, 2022
1 parent 4212d2b commit 68537d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/components/Validations/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const VALIDATIONS = {
'unique',
'differentFrom',
'sameAs',
'lessThanVariable',
'greaterThanVariable',
],
number: [
'required',
Expand All @@ -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',
Expand All @@ -40,6 +48,8 @@ const VALIDATIONS = {
'unique',
'differentFrom',
'sameAs',
'lessThanVariable',
'greaterThanVariable',
],
categorical: [
'required',
Expand All @@ -63,6 +73,8 @@ const VALIDATIONS_WITH_NUMBER_VALUES = [
const VALIDATIONS_WITH_LIST_VALUES = [
'differentFrom',
'sameAs',
'lessThanVariable',
'greaterThanVariable',
];

const isValidationWithNumberValue = (validation) => (
Expand Down
4 changes: 3 additions & 1 deletion src/components/sections/ValidationSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -24,6 +25,7 @@ const ValidationSection = ({
return true;
};

const existingVariablesForType = filter(existingVariables, (variable) => get(variable, 'type') === variableType);
return (
<Section
disabled={disabled}
Expand All @@ -43,7 +45,7 @@ const ValidationSection = ({
form={form}
name="validation"
variableType={variableType}
existingVariables={existingVariables}
existingVariables={existingVariablesForType}
/>
</Row>
</Section>
Expand Down

0 comments on commit 68537d9

Please sign in to comment.