@tstdl/base 0.91.0-beta7 → 0.91.0-beta8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.91.0-beta7",
3
+ "version": "0.91.0-beta8",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,8 +1,8 @@
1
- import type { JsonPath } from '../../json-path/json-path.js';
2
1
  import { type SchemaPropertyDecorator, type SchemaPropertyDecoratorOptions } from '../decorators/index.js';
3
- import { Schema, type SchemaTestOptions, type SchemaTestResult } from '../schema.js';
4
- export declare class FunctionSchema extends Schema<Function> {
5
- _test(value: any, path: JsonPath, options: SchemaTestOptions): SchemaTestResult<Function>;
2
+ import { SimpleSchema, type SimpleSchemaOptions } from './simple.js';
3
+ export type FunctionSchemaOptions = SimpleSchemaOptions;
4
+ export declare class FunctionSchema extends SimpleSchema<Function> {
5
+ constructor(options?: FunctionSchemaOptions);
6
6
  }
7
7
  export declare function func(): FunctionSchema;
8
8
  export declare function Function(options?: SchemaPropertyDecoratorOptions): SchemaPropertyDecorator;
@@ -1,14 +1,9 @@
1
- import { SchemaError } from '../../schema/schema.error.js';
2
1
  import { isFunction } from '../../utils/type-guards.js';
3
- import { typeOf } from '../../utils/type-of.js';
4
2
  import { Property } from '../decorators/index.js';
5
- import { Schema } from '../schema.js';
6
- export class FunctionSchema extends Schema {
7
- _test(value, path, options) {
8
- if (isFunction(value)) {
9
- return { valid: true, value };
10
- }
11
- return { valid: false, error: SchemaError.expectedButGot('Function', typeOf(value), path, { fast: options.fastErrors }) };
3
+ import { SimpleSchema } from './simple.js';
4
+ export class FunctionSchema extends SimpleSchema {
5
+ constructor(options) {
6
+ super('function', isFunction, options);
12
7
  }
13
8
  }
14
9
  export function func() {
@@ -2,6 +2,7 @@ import { isFunction } from '../utils/type-guards.js';
2
2
  import { Schema } from './schema.js';
3
3
  import { bigint } from './schemas/bigint.js';
4
4
  import { boolean } from './schemas/boolean.js';
5
+ import { func } from './schemas/function.js';
5
6
  import { number } from './schemas/number.js';
6
7
  import { getSchemaFromReflection } from './schemas/object.js';
7
8
  import { string } from './schemas/string.js';
@@ -21,6 +22,8 @@ export function schemaTestableToSchema(testable) {
21
22
  return bigint();
22
23
  case Symbol:
23
24
  return symbol();
25
+ case Function:
26
+ return func();
24
27
  default:
25
28
  return getSchemaFromReflection(testable);
26
29
  }
@@ -8,14 +8,14 @@ var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
10
  import { Singleton } from '../../injector/decorators.js';
11
- import { func, Union } from '../../schema/index.js';
11
+ import { Union } from '../../schema/index.js';
12
12
  import { TemplateField } from '../template.model.js';
13
13
  import { TemplateResolver } from '../template.resolver.js';
14
14
  export class StringTemplateField extends TemplateField {
15
15
  template;
16
16
  }
17
17
  __decorate([
18
- Union(String, func()),
18
+ Union(String, Function),
19
19
  __metadata("design:type", Object)
20
20
  ], StringTemplateField.prototype, "template", void 0);
21
21
  let StringTemplateResolver = class StringTemplateResolver extends TemplateResolver {