Skip to content

Commit

Permalink
Change picklist and union arg type #279
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-hiller committed Dec 8, 2023
1 parent 61a536c commit 7a61270
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 13 deletions.
1 change: 1 addition & 0 deletions library/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ All notable changes to the library will be documented in this file.
- Add `bic` validation function (pull request #284)
- Add `mac`, `mac48` and `mac64` validation function (pull request #270)
- Change `IntersectOptions`, `IntersectOptionsAsync`, `UnionOptions` and `UnionOptionsAsync` type to support readonly tuples (issue #279)
- Change `PicklistOptions`, `UnionOptions` and `UnionOptionsAsync` type from tuple to array (issue #279)
- Fix optional keys of `ObjectInput` and `ObjectOutput` type (issue #242)

## v0.22.0 (December 03, 2023)
Expand Down
2 changes: 1 addition & 1 deletion library/src/schemas/picklist/picklist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function picklist<
return schemaIssue(info, 'type', 'picklist', this.message, input);
}

// Return inpot as output
// Return input as output
return parseResult(true, input as TOptions[number]);
},
};
Expand Down
2 changes: 1 addition & 1 deletion library/src/schemas/picklist/picklistAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function picklistAsync<
return schemaIssue(info, 'type', 'picklist', this.message, input);
}

// Return inpot as output
// Return input as output
return parseResult(true, input as TOptions[number]);
},
};
Expand Down
2 changes: 1 addition & 1 deletion library/src/schemas/picklist/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import type { MaybeReadonly } from '../../types/index.ts';
* Picklist options type.
*/
export type PicklistOptions<TOption extends string = string> = MaybeReadonly<
[TOption, ...TOption[]]
TOption[]
>;
4 changes: 1 addition & 3 deletions library/src/schemas/union/union.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import { parseResult, schemaIssue } from '../../utils/index.ts';
/**
* Union options type.
*/
export type UnionOptions = MaybeReadonly<
[BaseSchema, BaseSchema, ...BaseSchema[]]
>;
export type UnionOptions = MaybeReadonly<BaseSchema[]>;

/**
* Union schema type.
Expand Down
8 changes: 1 addition & 7 deletions library/src/schemas/union/unionAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ import { parseResult, schemaIssue } from '../../utils/index.ts';
/**
* Union options async type.
*/
export type UnionOptionsAsync = MaybeReadonly<
[
BaseSchema | BaseSchemaAsync,
BaseSchema | BaseSchemaAsync,
...(BaseSchema[] | BaseSchemaAsync[])
]
>;
export type UnionOptionsAsync = MaybeReadonly<(BaseSchema | BaseSchemaAsync)[]>;

/**
* Union schema async type.
Expand Down

0 comments on commit 7a61270

Please sign in to comment.