Add and export types with the Validation error string literal values - #450
Add and export types with the Validation error string literal values#450joneubank wants to merge 1 commit into
Conversation
justincorrigible
left a comment
There was a problem hiding this comment.
this PR adds four new *Reason type aliases to @overture-stack/lectern-validation, but they're not re-exported from @overture-stack/lectern-client. is that something we want to consider? the curated list in packages/client/src/index.ts (i.e. already re-exporting these other existing types like DictionaryValidationError, FieldValidationError, etc.) doesn't include these new ones.
consumers likely import exclusively from lectern-client, not lectern-validation directly, so importing e.g. DictionaryValidationErrorReason the same way they already import DictionaryValidationRecordErrorDetails may be helpful (otherwise cause an error, or worse split where they import things from).
|
|
||
| export type SchemaValidationError = SchemaRecordError<SchemaValidationRecordErrorDetails>; | ||
|
|
||
| export type SchemaValidationErrorReason = SchemaValidationRecordErrorDetails['reason']; |
There was a problem hiding this comment.
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
|
|
||
| export type FieldValidationError = FieldValidationErrorRestrictions | FieldValidationErrorValueType; | ||
|
|
||
| export type FieldValidationErrorReason = FieldValidationError['reason']; |
There was a problem hiding this comment.
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?
Summary
Add additional type exports that contain the validation reason string literal types. These are derived from the Validation Error union types so if new validation rules are added the Reason types will inherit the added reasons.
Description of Changes
Validation
Added four new exported types which are unions of the error reason literals, for programmatic reference by importing libraries:
which resolve, at the moment, as:
Readiness Checklist
.env.schemafile and documented in the README