Skip to content

Commit

Permalink
feat(types): new NumberBetween and StringOfLength types
Browse files Browse the repository at this point in the history
  • Loading branch information
sciborrudnicki committed Jun 25, 2021
1 parent e70b034 commit a6b567f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/type/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ export { Func } from './func.type';
export { Key } from './key.type';
export { Never } from './never.type';
export { NotUndefined } from './not-undefined.type';
export { NumberBetween } from './number-between.type';
export { Primitive } from './primitive.type';
export { Primitives } from './primitives.type';
export { StringOfLength } from './string-of-length.type';
export { ResultCallback } from './result-callback.type';
export { Type } from './type.type';
export { Types } from './types.type';
10 changes: 10 additions & 0 deletions src/type/number-between.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { AnyNumber } from './any-number.type';
/**
* A `number` type or an instance of a `Number` with the specified range.
* Generic variables `Min` and `Max` are constrained with the `number` type.
*/
export type NumberBetween<Min extends number, Max extends number> =
AnyNumber & {
min: Min;
max: Max;
};
10 changes: 10 additions & 0 deletions src/type/string-of-length.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { AnyString } from './any-string.type';
/**
* A `string` type or an instance of a `String` with its specified minimum and maximum length.
* Generic variables `Min` and `Max` are constrained with the `number` type.
*/
export type StringOfLength<Min extends number, Max extends number> =
AnyString & {
min: Min;
max: Max;
};

0 comments on commit a6b567f

Please sign in to comment.