# acmepy/yep architecture

> Architecture diagram of the GitHub repository acmepy/yep, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/acmepy/yep
- Repository: https://github.com/acmepy/yep

## Overview

Yep is a small asynchronous JavaScript validation library. An application builds a field or object schema through the public `yep` API, configures types and chainable rules, then validates data; object validation returns validated values or errors, with an optional safe summary. The library also converts between Yep schemas and a documented subset of JSON Schema, and supports custom types and tests. The map follows sampled entry-point and field-validation code; some object-schema and rule wiring is included only where README capabilities and the source tree support it.

Main entry points: [`src/index.js`](https://github.com/acmepy/yep/blob/main/src/index.js) (Yep API), [`src/core/object-schema.js`](https://github.com/acmepy/yep/blob/main/src/core/object-schema.js) (Object Schema), [`src/core/base-type.js`](https://github.com/acmepy/yep/blob/main/src/core/base-type.js) (Field Validation), [`src/json-schema/from-json-schema.js`](https://github.com/acmepy/yep/blob/main/src/json-schema/from-json-schema.js) (JSON Schema Import)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Schema API"]
  node_public_api["Yep API<br/>[index.js]"]
  node_object_schema["Object Schema<br/>[object-schema.js]"]
  node_field_type["Field Schema<br/>[base-type.js]"]
  node_built_in_types["Built-in Types"]
  node_date_normalization["Date Normalization<br/>[date.js]"]
end

subgraph group_validation["Validation"]
  node_rule_modules["Built-in Rules"]
  node_field_validation["Field Validation<br/>[base-type.js]"]
  node_object_validation["Object Validation<br/>[object-schema.js]"]
  node_error_messages["Error Messages<br/>[messages.js]"]
  node_validation_error["Validation Error"]
end

subgraph group_extensions["Extensibility"]
  node_rule_registry["Rule Registry<br/>[registry.js]"]
  node_custom_rules["Custom Rules<br/>[custom.js]"]
end

subgraph group_conversion["Schema Conversion"]
  node_json_import["JSON Schema Import"]
  node_json_export["JSON Schema Export<br/>[to-json-schema.js]"]
end

node_application(("Application"))
node_external_validator(("Application Validator"))

node_application -->|"configures and validates"| node_public_api
node_public_api -->|"creates"| node_object_schema
node_public_api -->|"creates types"| node_built_in_types
node_public_api -->|"registers extensions"| node_rule_registry
node_object_schema -->|"defines fields"| node_field_type
node_object_schema -->|"validates object"| node_object_validation
node_field_type -->|"validates field"| node_field_validation
node_field_type -->|"normalizes dates"| node_date_normalization
node_field_validation -->|"runs rules"| node_rule_modules
node_field_validation -->|"formats errors"| node_error_messages
node_field_validation -->|"throws"| node_validation_error
node_object_validation -->|"validates fields"| node_field_validation
node_object_validation -->|"aggregates errors"| node_validation_error
node_rule_registry -->|"registers"| node_custom_rules
node_custom_rules -->|"invokes callback"| node_external_validator
node_field_type -->|"exports schema"| node_json_export
node_object_schema -->|"exports schema"| node_json_export
node_public_api -->|"imports schema"| node_json_import
node_json_import -->|"creates object schema"| node_object_schema
node_json_import -->|"creates field types"| node_built_in_types

click node_public_api "https://github.com/acmepy/yep/blob/main/src/index.js"
click node_object_schema "https://github.com/acmepy/yep/blob/main/src/core/object-schema.js"
click node_field_type "https://github.com/acmepy/yep/blob/main/src/core/base-type.js"
click node_built_in_types "https://github.com/acmepy/yep/tree/main/src/types"
click node_date_normalization "https://github.com/acmepy/yep/blob/main/src/types/date.js"
click node_rule_registry "https://github.com/acmepy/yep/blob/main/src/core/registry.js"
click node_rule_modules "https://github.com/acmepy/yep/tree/main/src/tests"
click node_custom_rules "https://github.com/acmepy/yep/blob/main/src/tests/custom.js"
click node_field_validation "https://github.com/acmepy/yep/blob/main/src/core/base-type.js"
click node_object_validation "https://github.com/acmepy/yep/blob/main/src/core/object-schema.js"
click node_error_messages "https://github.com/acmepy/yep/blob/main/src/errors/messages.js"
click node_validation_error "https://github.com/acmepy/yep/blob/main/src/errors/validation-error.js"
click node_json_import "https://github.com/acmepy/yep/blob/main/src/json-schema/from-json-schema.js"
click node_json_export "https://github.com/acmepy/yep/blob/main/src/json-schema/to-json-schema.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_api,node_object_schema,node_field_type,node_built_in_types,node_date_normalization toneBlue
class node_rule_modules,node_field_validation,node_object_validation,node_error_messages,node_validation_error toneAmber
class node_rule_registry,node_custom_rules toneMint
class node_json_import,node_json_export toneRose
class node_application,node_external_validator toneIndigo
```

## Components

### Schema API

- [Yep API](https://github.com/acmepy/yep/blob/main/src/index.js): `src/index.js`
- [Object Schema](https://github.com/acmepy/yep/blob/main/src/core/object-schema.js): `src/core/object-schema.js`
- [Field Schema](https://github.com/acmepy/yep/blob/main/src/core/base-type.js): `src/core/base-type.js`
- [Built-in Types](https://github.com/acmepy/yep/tree/main/src/types): `src/types`
- [Date Normalization](https://github.com/acmepy/yep/blob/main/src/types/date.js): `src/types/date.js`

### Validation

- [Built-in Rules](https://github.com/acmepy/yep/tree/main/src/tests): `src/tests`
- [Field Validation](https://github.com/acmepy/yep/blob/main/src/core/base-type.js): `src/core/base-type.js`
- [Object Validation](https://github.com/acmepy/yep/blob/main/src/core/object-schema.js): `src/core/object-schema.js`
- [Error Messages](https://github.com/acmepy/yep/blob/main/src/errors/messages.js): `src/errors/messages.js`
- [Validation Error](https://github.com/acmepy/yep/blob/main/src/errors/validation-error.js): `src/errors/validation-error.js`

### Extensibility

- [Rule Registry](https://github.com/acmepy/yep/blob/main/src/core/registry.js): `src/core/registry.js`
- [Custom Rules](https://github.com/acmepy/yep/blob/main/src/tests/custom.js): `src/tests/custom.js`

### Schema Conversion

- [JSON Schema Import](https://github.com/acmepy/yep/blob/main/src/json-schema/from-json-schema.js): `src/json-schema/from-json-schema.js`
- [JSON Schema Export](https://github.com/acmepy/yep/blob/main/src/json-schema/to-json-schema.js): `src/json-schema/to-json-schema.js`

### Other components

- **Application**
- **Application Validator**

## Connections

- Application → Yep API: configures and validates
- Yep API → Object Schema: creates
- Yep API → Built-in Types: creates types
- Yep API → Rule Registry: registers extensions
- Object Schema → Field Schema: defines fields
- Object Schema → Object Validation: validates object
- Field Schema → Field Validation: validates field
- Field Schema → Date Normalization: normalizes dates
- Field Validation → Built-in Rules: runs rules
- Field Validation → Error Messages: formats errors
- Field Validation → Validation Error: throws
- Object Validation → Field Validation: validates fields
- Object Validation → Validation Error: aggregates errors
- Rule Registry → Custom Rules: registers
- Custom Rules → Application Validator: invokes callback
- Field Schema → JSON Schema Export: exports schema
- Object Schema → JSON Schema Export: exports schema
- Yep API → JSON Schema Import: imports schema
- JSON Schema Import → Object Schema: creates object schema
- JSON Schema Import → Built-in Types: creates field types
