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
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ export type DictionaryValidationErrorInvalidRecords = DictionaryValidationErrorB
export type DictionaryValidationError =
| DictionaryValidationErrorUnrecognizedSchema
| DictionaryValidationErrorInvalidRecords;

export type DictionaryValidationErrorReason = DictionaryValidationError['reason'];
2 changes: 2 additions & 0 deletions packages/validation/src/validateField/FieldValidationError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ export type FieldValidationErrorValueType = {
};

export type FieldValidationError = FieldValidationErrorRestrictions | FieldValidationErrorValueType;

export type FieldValidationErrorReason = FieldValidationError['reason'];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the 4 new exports in the PR have a TSDoc comment, which looks like it breaks with this file's own existing convention, FieldValidationErrorValueType right next to this one has one.

do we want to add a brief one-liner to each stating what the type represents?

Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ export type RecordValidationError =
| RecordValidationErrorInvalidValue
| RecordValidationErrorRestrictions
| RecordValidationErrorUnrecognizedField;

export type RecordValidationErrorReason = RecordValidationError['reason'];
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ export type SchemaRecordError<ErrorDetails> = {
};

export type SchemaValidationError = SchemaRecordError<SchemaValidationRecordErrorDetails>;

export type SchemaValidationErrorReason = SchemaValidationRecordErrorDetails['reason'];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth a one-line comment here recording the deviation: the other three *Reason aliases all follow <X>Reason = X['reason'], but this one is derived from the nested SchemaValidationRecordErrorDetails instead, since SchemaValidationError itself has no top-level reason field... that's the right call, but undocumented it reads as an inconsistency rather than a deliberate exception, and a future contributor extending the pattern "by analogy" will likely hit some type error trying to do what "seems" obvious