Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanbond committed Apr 17, 2024
1 parent 672b0ed commit 93bcd9a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/modules/jsonlogic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export type EvaluatorContext = {
export type EvaluatorFn = (context: EvaluatorContext) => any;

export function evaluate(
context: EvaluatorContext,
evaluation: string,
ret: string = 'result',
context: EvaluatorContext,
evaluation: string,
ret: string = 'result',
evalContextFn?: EvaluatorFn,
fnName?: string,
options: any = {}
Expand All @@ -49,8 +49,8 @@ export function evaluate(
}

export function interpolate(
context: EvaluatorContext,
evaluation: string,
context: EvaluatorContext,
evaluation: string,
evalContextFn?: EvaluatorFn
) : string {
return evaluate(context, evaluation, undefined, evalContextFn, 'interpolate', {
Expand Down
12 changes: 6 additions & 6 deletions src/process/validation/rules/__tests__/validateRequired.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ it('Validating a simple component that is required and present in the data will
});


it('Validating a simple radio component that is required and present in the data with value=false will return null', async () => {
it('Validating a simple radio component that is required and present in the data with value set to false will return null', async () => {
const component = { ...simpleRadioField, validate: { required: true }, values: [
{
label: 'Yes',
Expand All @@ -38,13 +38,13 @@ it('Validating a simple radio component that is required and present in the data
value: 'false',
}] };
const data = { component: false };
const context = generateProcessContext(component, data);
const context = generateProcessorContext(component, data);
const result = await validateRequired(context);
expect(result).to.equal(null);
});


it('Validating a simple selectbox that is required and present in the data with value=0 will return null', async () => {
it('Validating a simple selectbox that is required and present in the data with value set to zero will return null', async () => {
const component = { ...simpleSelectBoxes, validate: { required: true }, values: [
{
label: 'true',
Expand All @@ -55,12 +55,12 @@ it('Validating a simple selectbox that is required and present in the data with
value: '0',
}] };
const data = { component: 0 };
const context = generateProcessContext(component, data);
const context = generateProcessorContext(component, data);
const result = await validateRequired(context);
expect(result).to.equal(null);
});

it('Validating a simple selectbox that is required and present in the data with value=false will return null', async () => {
it('Validating a simple selectbox that is required and present in the data with value set to false will return null', async () => {
const component = { ...simpleSelectBoxes, validate: { required: true }, values: [
{
label: 'true',
Expand All @@ -71,7 +71,7 @@ it('Validating a simple selectbox that is required and present in the data with
value: 'false',
}] };
const data = { component: false };
const context = generateProcessContext(component, data);
const context = generateProcessorContext(component, data);
const result = await validateRequired(context);
expect(result).to.equal(null);
});
Expand Down
4 changes: 2 additions & 2 deletions src/process/validation/rules/validateRequired.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const validateRequiredSync: RuleFnSync = (context: ValidationContext) =>
return null;
}
if (
(value === null || value === undefined || isEmptyObject(value) || (!!value === false && value !== 0 && value !==false )) &&
(value === null || value === undefined || isEmptyObject(value) || (!!value === false && value !== 0 && value !== false )) &&
!component.hidden
) {
return error;
Expand All @@ -51,4 +51,4 @@ export const validateRequiredInfo: ProcessorInfo<ValidationContext, FieldError |
process: validateRequired,
processSync: validateRequiredSync,
shouldProcess: shouldValidate,
};
};

0 comments on commit 93bcd9a

Please sign in to comment.