# core/selectors/record.selector.ts

> 20 lines of code and 6 definitions.

Tree: GovLab Docs
Language: typescript
Layer: application
Canonical: https://banes-lab.com/anatomy/docs#file-docs-core-selectors-record-selector-ts
Source text: https://banes-lab.com/source/docs/core/selectors/record.selector.ts.txt

Listed in [core/selectors](https://banes-lab.com/api/source/docs/core/selectors.md), after [core/selectors/program.selector.ts](https://banes-lab.com/source/docs/core/selectors/program.selector.ts.md) and before [core/selectors/surface.selector.ts](https://banes-lab.com/source/docs/core/selectors/surface.selector.ts.md).

## Definitions

- `isNonEmptyStringArray` (lexical_declaration, line 23, exported)
- `arrayField` (lexical_declaration, line 14, exported)
- `recordField` (lexical_declaration, line 4, exported)
- `stringField` (lexical_declaration, line 9, exported)
- `value` (lexical_declaration, line 15, exported)
- `stringsOf` (lexical_declaration, line 19, exported)

## Contained in

- [core/selectors](https://banes-lab.com/anatomy/docs/folder-docs-core-selectors.md)

## Uses

- [core/predicates/record.predicate.ts](https://banes-lab.com/source/docs/core/predicates/record.predicate.ts.md)

## Used by

- [core/formatters/coverage.formatter.ts](https://banes-lab.com/source/docs/core/formatters/coverage.formatter.ts.md)
- [core/plugins/manifest.catalog.plugin.ts](https://banes-lab.com/source/docs/core/plugins/manifest.catalog.plugin.ts.md)
- [core/plugins/manifest.grammar.plugin.ts](https://banes-lab.com/source/docs/core/plugins/manifest.grammar.plugin.ts.md)
- [core/plugins/manifest.principle.plugin.ts](https://banes-lab.com/source/docs/core/plugins/manifest.principle.plugin.ts.md)
- [core/plugins/manifest.quality.plugin.ts](https://banes-lab.com/source/docs/core/plugins/manifest.quality.plugin.ts.md)
- [core/plugins/manifest.surface.plugin.ts](https://banes-lab.com/source/docs/core/plugins/manifest.surface.plugin.ts.md)
- [core/registries/manifest.registry.ts](https://banes-lab.com/source/docs/core/registries/manifest.registry.ts.md)

## Linked from

- [core/formatters](https://banes-lab.com/anatomy/docs/folder-docs-core-formatters.md)
- [core/plugins](https://banes-lab.com/anatomy/docs/folder-docs-core-plugins.md)
- [core/predicates](https://banes-lab.com/anatomy/docs/folder-docs-core-predicates.md)
- [core/registries](https://banes-lab.com/anatomy/docs/folder-docs-core-registries.md)

## Source

```typescript
import type { Manifest } from "#types/readme.types";
import { isPlainRecord } from "#core/predicates/record.predicate";

export const recordField = function recordField(record: Manifest, key: string): Manifest | null {
    const value = record[key];
    return isPlainRecord(value) ? value : null;
};

export const stringField = function stringField(record: Manifest, key: string): string | null {
    const value = record[key];
    return typeof value === "string" ? value : null;
};

export const arrayField = function arrayField(record: Manifest, key: string): unknown[] {
    const value = record[key];
    return Array.isArray(value) ? value : [];
};

export const stringsOf = function stringsOf(value: unknown): string[] {
    return Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === "string") : [];
};

export const isNonEmptyStringArray = function isNonEmptyStringArray(value: unknown): value is string[] {
    return Array.isArray(value) && value.every((entry) => typeof entry === "string" && entry.trim().length > 0);
};
```
