Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions docs/03-dictionaryReference.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ Optional components like descriptions, metadata, and references which can also b

| Property | Type | Required | Description | Example |
| ------------- | -------- | -------- | -------------------------------------- | ----------------------------------------- |
| `name` | `string` | ✓ | Display name of the dictionary | `"clinical_data_dictionary"` |
| `name` | `string` | ✓ | Name of the dictionary | `"clinical_data_dictionary"` |
| `version` | `string` | ✓ | Semantic version (major.minor.patch) | `"1.2.0"` |
| `schemas` | `Array` | ✓ | List of schema definitions (minimum 1) | See [Schema Structure](#schema-structure) |
| `description` | `string` | ✗ | A human-readable description | `"Clinical trial data schemas"` |
| `displayName` | `string` | ✗ | Display name of the dictionary | `"Clinical Data Dictionary"` |
| `meta` | `object` | ✗ | Any custom defined metadata fields | `{"author": "Clinical Data Team"}` |
| `references` | `object` | ✗ | Reusable reference values | See [References](#references) |

Expand Down Expand Up @@ -75,13 +76,13 @@ At the schema-level descriptions and metadata can also be optionally added.

#### Schema Properties

| Property | Type | Required | Description |
| ------------- | -------- | -------- | ------------------------------------------------------------------ |
| `name` | `string` | ✓ | The schema identifier (no spaces or dots) |
| `displayName` | `string` | ✗ | A human-readable name for UI display. Can contain periods. |
| `fields` | `Array` | ✓ | List of field definitions, see [Field Structure](#field-structure) |
| `description` | `string` | ✗ | A human-readable description |
| `meta` | `object` | ✗ | Any custom defined metadata fields |
| Property | Type | Required | Description |
| ------------- | -------- | -------- | -------------------------------------------------------------------------------------------- |
| `name` | `string` | ✓ | The schema identifier. Typically a short name with no spaces. Cannot contain `.` characters. |
| `displayName` | `string` | ✗ | A human-readable name for UI display. No format restrictions. |
| `fields` | `Array` | ✓ | List of field definitions, see [Field Structure](#field-structure) |
| `description` | `string` | ✗ | A human-readable description |
| `meta` | `object` | ✗ | Any custom defined metadata fields |

## Field Structure

Expand Down Expand Up @@ -140,17 +141,17 @@ The allowed values for `valueType` include:

At the field-level the following properties can also be included:

| Property | Type | Required | Default | Description |
| -------------- | -------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------- |
| `name` | `string` | ✓ | - | Field identifier (used as a column header) |
| `displayName` | `string` | ✗ | - | A human-readable name for UI display. Can contain periods. |
| `description` | `string` | ✗ | `""` | Human-readable description |
| `valueType` | `string` | ✓ | - | Data type: `string`, `integer`, `number`, `boolean` |
| `isArray` | `boolean` | ✗ | `false` | Whether field accepts multiple values |
| `delimiter` | `string` | ✗ | `","` | Separator for array values |
| `unique` | `boolean` | ✗ | `false` | Whether values must be unique across records |
| `restrictions` | `object/array` | ✗ | `{}` | Where the validation rules/logic for the field is defined, see [Field Restrictions](#field-restrictions) |
| `meta` | `object` | ✗ | `{}` | Any custom defined metadata fields |
| Property | Type | Required | Default | Description |
| -------------- | -------------- | -------- | ------- | ----------------------------------------------------------------------------------------------------------------- |
| `name` | `string` | ✓ | - | Field identifier (used as a column header). Typically a short name with no spaces. Cannot contain `.` characters. |
| `displayName` | `string` | ✗ | - | A human-readable name for UI display. Can contain periods. |
| `description` | `string` | ✗ | `""` | Human-readable description |
| `valueType` | `string` | ✓ | - | Data type: `string`, `integer`, `number`, `boolean` |
| `isArray` | `boolean` | ✗ | `false` | Whether field accepts multiple values |
| `delimiter` | `string` | ✗ | `","` | Separator for array values |
| `unique` | `boolean` | ✗ | `false` | Whether values must be unique across records |
| `restrictions` | `object/array` | ✗ | `{}` | Where the validation rules/logic for the field is defined, see [Field Restrictions](#field-restrictions) |
| `meta` | `object` | ✗ | `{}` | Any custom defined metadata fields |

### Display Name Example

Expand Down
16 changes: 12 additions & 4 deletions packages/dictionary/src/metaSchema/dictionarySchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,27 @@ import {
} from './restrictionsSchemas';

/**
* String rules for all name fields used in dictionary, including Dictionary, Schema, and Fields.
* String rules for all name fields used in dictionary Schema, and Fields.
* This validates the format of the string since names are not allowed to have `.` characters.
*
* Example Values:
* - `donors`
* - `primary-site`
* - `maximumVelocity`
*/
*
* Note: This is not used for dictionary names, to support legacy dictionary data.
* */
export const NameValue = zod
.string()
.min(1, 'Name fields cannot be empty.')
.regex(/^[^.]+$/, 'Name fields cannot have `.` characters.');
export type NameValue = zod.infer<typeof NameValue>;

/**
* Common validation rules for `displayName` for all entities: Dictionary, Schema, and Field
*/
export const DisplayNameValue = zod.string().min(1).optional();

// Meta accepts as values only strings, numbers, booleans, arrays of numbers or arrays of strings
// Another Meta object can be nested inside a Meta property
export const DictionaryMetaValue = zod.union([
Expand Down Expand Up @@ -180,9 +187,9 @@ export type AnyFieldRestrictions = zod.infer<typeof AnyFieldRestrictions>;
export const SchemaFieldBase = zod
.object({
name: NameValue,
displayName: zod.string().optional(),
description: zod.string().optional(),
delimiter: zod.string().min(1).optional(),
displayName: DisplayNameValue,
isArray: zod.boolean().optional(),
meta: DictionaryMeta.optional(),
unique: zod.boolean().optional(),
Expand Down Expand Up @@ -249,8 +256,8 @@ export type ForeignKeyRestriction = zod.infer<typeof ForeignKeyRestriction>;
export const Schema = zod
.object({
name: NameValue,
displayName: zod.string().optional(),
description: zod.string().optional(),
displayName: DisplayNameValue,
fields: zod.array(SchemaField).min(1),
meta: DictionaryMeta.optional(),
restrictions: zod
Expand Down Expand Up @@ -329,6 +336,7 @@ export const DictionaryBase = zod
.object({
name: zod.string().min(1),
description: zod.string().optional(),
displayName: DisplayNameValue,
meta: DictionaryMeta.optional(),
references: References.optional(),
schemas: zod.array(Schema).min(1),
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/viewer-table/DictionaryHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const DictionaryHeader = () => {
const { loading } = dataContext;
const { selectedDictionary } = stateContext;

const displayName = selectedDictionary?.displayName ?? selectedDictionary?.name;
const version = selectedDictionary?.version;
const description = selectedDictionary?.description;

Expand All @@ -83,7 +84,7 @@ const DictionaryHeader = () => {
}
return (
<div css={containerStyle}>
<h1 css={titleStyle(theme)}>{selectedDictionary?.name}</h1>
<h1 css={titleStyle(theme)}>{displayName}</h1>
{description && (
<ReadMoreText
maxLines={2}
Expand Down