{"version":3,"file":"number.cjs","names":["BaseSchema"],"sources":["../../src/schemas/number.ts"],"sourcesContent":["import { BaseSchema } from \"../core/base\";\nimport type { CombinedStandardProps, SchemaPrimitive } from \"../core/types\";\n\nexport class NumberSchemaType extends BaseSchema<unknown, number> {\n  readonly type: SchemaPrimitive = \"number\";\n  private _min?: number;\n  private _max?: number;\n  private _int = false;\n\n  constructor() {\n    super();\n    this.jsonSchema = { type: \"number\" };\n  }\n\n  primitive(): SchemaPrimitive {\n    return this.type;\n  }\n\n  /**\n   * Require minimum numeric value.\n   * @param {number} n Minimum value.\n   * @returns {NumberSchemaType} New constrained schema.\n   */\n  min(n: number): NumberSchemaType {\n    const schema = new NumberSchemaType();\n    Object.assign(schema, this);\n    schema._min = n;\n    schema.jsonSchema = { ...this.jsonSchema, minimum: n };\n    return schema;\n  }\n\n  /**\n   * Require maximum numeric value.\n   * @param {number} n Maximum value.\n   * @returns {NumberSchemaType} New constrained schema.\n   */\n  max(n: number): NumberSchemaType {\n    const schema = new NumberSchemaType();\n    Object.assign(schema, this);\n    schema._max = n;\n    schema.jsonSchema = { ...this.jsonSchema, maximum: n };\n    return schema;\n  }\n\n  /**\n   * Require integer values only.\n   * @returns {NumberSchemaType} New constrained schema.\n   */\n  int(): NumberSchemaType {\n    const schema = new NumberSchemaType();\n    Object.assign(schema, this);\n    schema._int = true;\n    schema.jsonSchema = { ...this.jsonSchema, type: \"integer\" };\n    return schema;\n  }\n\n  get [\"~standard\"](): CombinedStandardProps<unknown, number> {\n    return {\n      version: 1,\n      vendor: \"h-schema\",\n      jsonSchema: {\n        input: () => this.jsonSchema,\n        output: () => this.jsonSchema,\n      },\n      validate: (value: unknown) => {\n        if (this._coerce && typeof value !== \"number\") {\n          const coerced = Number(value);\n          if (!Number.isNaN(coerced)) {\n            value = coerced;\n          }\n        }\n        if (typeof value !== \"number\" || Number.isNaN(value)) {\n          return { issues: [{ message: `Expected number, received ${typeof value}` }] };\n        }\n        if (this._int && !Number.isInteger(value)) {\n          return { issues: [{ message: \"Expected integer\" }] };\n        }\n        if (this._min !== undefined && value < this._min) {\n          return { issues: [{ message: `Number less than ${this._min}` }] };\n        }\n        if (this._max !== undefined && value > this._max) {\n          return { issues: [{ message: `Number greater than ${this._max}` }] };\n        }\n        return { value };\n      },\n      types: {\n        input: {} as unknown,\n        output: {} as number,\n      },\n    };\n  }\n}\n"],"mappings":";;AAGA,IAAa,mBAAb,MAAa,yBAAyBA,aAAAA,WAA4B;CAChE,OAAiC;CACjC;CACA;CACA,OAAe;CAEf,cAAc;EACZ,MAAM;EACN,KAAK,aAAa,EAAE,MAAM,SAAS;CACrC;CAEA,YAA6B;EAC3B,OAAO,KAAK;CACd;;;;;;CAOA,IAAI,GAA6B;EAC/B,MAAM,SAAS,IAAI,iBAAiB;EACpC,OAAO,OAAO,QAAQ,IAAI;EAC1B,OAAO,OAAO;EACd,OAAO,aAAa;GAAE,GAAG,KAAK;GAAY,SAAS;EAAE;EACrD,OAAO;CACT;;;;;;CAOA,IAAI,GAA6B;EAC/B,MAAM,SAAS,IAAI,iBAAiB;EACpC,OAAO,OAAO,QAAQ,IAAI;EAC1B,OAAO,OAAO;EACd,OAAO,aAAa;GAAE,GAAG,KAAK;GAAY,SAAS;EAAE;EACrD,OAAO;CACT;;;;;CAMA,MAAwB;EACtB,MAAM,SAAS,IAAI,iBAAiB;EACpC,OAAO,OAAO,QAAQ,IAAI;EAC1B,OAAO,OAAO;EACd,OAAO,aAAa;GAAE,GAAG,KAAK;GAAY,MAAM;EAAU;EAC1D,OAAO;CACT;CAEA,KAAK,eAAuD;EAC1D,OAAO;GACL,SAAS;GACT,QAAQ;GACR,YAAY;IACV,aAAa,KAAK;IAClB,cAAc,KAAK;GACrB;GACA,WAAW,UAAmB;IAC5B,IAAI,KAAK,WAAW,OAAO,UAAU,UAAU;KAC7C,MAAM,UAAU,OAAO,KAAK;KAC5B,IAAI,CAAC,OAAO,MAAM,OAAO,GACvB,QAAQ;IAEZ;IACA,IAAI,OAAO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