Skip to content

Commit

Permalink
TS comments for functions rangeToText and isValidValueType
Browse files Browse the repository at this point in the history
  • Loading branch information
joneubank committed Jul 31, 2024
1 parent 9e74501 commit b484be4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/validation/src/utils/isValidValueType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
import type { DataRecordValue, SchemaField } from 'dictionary';
import { isBooleanArray, isInteger, isIntegerArray, isNumber, isNumberArray, isStringArray } from './typeUtils';

/**
* Checks that a value matches the expected type for a given field, based on the value type specified in its field
* definition.
*
* @param value Value to check
* @param fieldDefinition Field definition that specifies the expected value type
* @returns `true` if value matches the expected type; `false` otherwise.
*/
export const isValidValueType = (value: DataRecordValue, fieldDefinition: SchemaField): boolean => {
switch (fieldDefinition.valueType) {
case 'boolean': {
Expand Down
10 changes: 10 additions & 0 deletions packages/validation/src/utils/rangeToText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@

import { RestrictionRange } from 'dictionary';

/**
* Convert a RestrictionRange object to a simple string representation.
*
* @example
* const range = { exclusiveMin: 0, max: 10 };
* rangeToText(range); // "> 0 and <= 10"
*
* @param range
* @returns
*/
export const rangeToText = (range: RestrictionRange): string => {
let minString = '';
let maxString = '';
Expand Down

0 comments on commit b484be4

Please sign in to comment.