Skip to content

Commit

Permalink
fixup! WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Mar 24, 2024
1 parent 5459337 commit 97ae92a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/constraint.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { normalize } from "./error.js";
import { createConjunctionFormatter } from "./list.js";

export type DeclarationConstraintOptions<T> = {
readonly constraints?: ExtrinsicConstraint<T>[];
};

export type Constraint<T> = IntrinsicConstraint<T> | ExtrinsicConstraint<T>;

export type IntrinsicConstraint<T> = {
Expand Down
10 changes: 6 additions & 4 deletions src/declaration/big-integer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import type { Constraint, ExtrinsicConstraint } from "../constraint.js";
import type {
Constraint,
DeclarationConstraintOptions,
} from "../constraint.js";
import {
createRangeConstraint,
hasBigintRangeConstraint,
Expand All @@ -22,10 +25,9 @@ import { resolve } from "../maybe.js";
import { ScalarSchema, createScalar, toString } from "../schema.js";

export type Options = DeclarationOptions<bigint> &
DeclarationConstraintOptions<bigint> &
DeclarationExampleOptions<bigint> &
Partial<RangeConstraintSpec<bigint>> & {
readonly constraints?: ExtrinsicConstraint<bigint>[];
};
Partial<RangeConstraintSpec<bigint>>;

export function bigInteger<O extends Options>(
name: string,
Expand Down
7 changes: 5 additions & 2 deletions src/declaration/binary.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Buffer } from "node:buffer";
import type { Constraint, ExtrinsicConstraint } from "../constraint.js";
import type {
Constraint,
DeclarationConstraintOptions,
} from "../constraint.js";
import {
createLengthConstraint,
type LengthConstraintSpec,
Expand Down Expand Up @@ -27,8 +30,8 @@ const PATTERNS: Partial<Record<BufferEncoding, RegExp>> = {
} as const;

export type Options = DeclarationOptions<Buffer> &
DeclarationConstraintOptions<Buffer> &
DeclarationExampleOptions<Buffer> & {
readonly constraints?: ExtrinsicConstraint<Buffer>[];
readonly encoding?: BufferEncoding;
readonly length?: LengthConstraintSpec;
};
Expand Down
7 changes: 5 additions & 2 deletions src/declaration/string.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import type { Constraint, ExtrinsicConstraint } from "../constraint.js";
import type {
Constraint,
DeclarationConstraintOptions,
} from "../constraint.js";
import {
createLengthConstraint,
type LengthConstraintSpec,
Expand All @@ -21,8 +24,8 @@ import { resolve } from "../maybe.js";
import { createString, type ScalarSchema } from "../schema.js";

export type Options = DeclarationOptions<string> &
DeclarationConstraintOptions<string> &
DeclarationExampleOptions<string> & {
readonly constraints?: ExtrinsicConstraint<string>[];
readonly length?: LengthConstraintSpec;
};

Expand Down

0 comments on commit 97ae92a

Please sign in to comment.