@warlock.js/notifications 5.28.0 → 5.30.0
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/CHANGELOG.md +12 -0
- package/cjs/{channel_api-CBB_XoIl.cjs → channel_api-C5ZZDkgQ.cjs} +21 -21
- package/cjs/channel_api-C5ZZDkgQ.cjs.map +1 -0
- package/cjs/index.cjs +22 -22
- package/cjs/index.cjs.map +1 -1
- package/cjs/rabbitmq-driver-BFoWr21L.cjs +3 -0
- package/cjs/{src-B6UVThgW.cjs → src-eu2jxS21.cjs} +173 -135
- package/cjs/src-eu2jxS21.cjs.map +1 -0
- package/esm/channels/database-channel.d.mts +1 -1
- package/esm/channels/database-channel.d.mts.map +1 -1
- package/esm/channels/database-channel.mjs +1 -1
- package/esm/channels/database-channel.mjs.map +1 -1
- package/esm/channels/mail-channel.d.mts +1 -1
- package/esm/channels/mail-channel.d.mts.map +1 -1
- package/esm/channels/mail-channel.mjs +1 -1
- package/esm/channels/mail-channel.mjs.map +1 -1
- package/esm/config.d.mts +1 -1
- package/esm/config.d.mts.map +1 -1
- package/esm/config.mjs +1 -1
- package/esm/config.mjs.map +1 -1
- package/esm/contracts/channel.contract.d.mts +1 -1
- package/esm/contracts/channel.contract.d.mts.map +1 -1
- package/esm/contracts/notification.contract.d.mts +1 -1
- package/esm/contracts/notification.contract.d.mts.map +1 -1
- package/esm/contracts/preference-provider.contract.d.mts +1 -1
- package/esm/contracts/preference-provider.contract.d.mts.map +1 -1
- package/esm/contracts/queue-dispatcher.contract.d.mts +1 -1
- package/esm/contracts/queue-dispatcher.contract.d.mts.map +1 -1
- package/esm/contracts/rate-limiter.contract.d.mts +1 -1
- package/esm/contracts/rate-limiter.contract.d.mts.map +1 -1
- package/esm/dispatch/define-channel.d.mts +1 -1
- package/esm/dispatch/define-channel.d.mts.map +1 -1
- package/esm/dispatch/define-channel.mjs +1 -1
- package/esm/dispatch/define-channel.mjs.map +1 -1
- package/esm/dispatch/define-notification.d.mts +1 -1
- package/esm/dispatch/define-notification.d.mts.map +1 -1
- package/esm/dispatch/define-notification.mjs +1 -1
- package/esm/dispatch/define-notification.mjs.map +1 -1
- package/esm/dispatch/dispatch-id.mjs +1 -1
- package/esm/dispatch/dispatch-id.mjs.map +1 -1
- package/esm/dispatch/dispatcher.mjs +1 -1
- package/esm/dispatch/dispatcher.mjs.map +1 -1
- package/esm/dispatch/notifications-event-bus.d.mts +1 -1
- package/esm/dispatch/notifications-event-bus.d.mts.map +1 -1
- package/esm/dispatch/notifications-event-bus.mjs +1 -1
- package/esm/dispatch/notifications-event-bus.mjs.map +1 -1
- package/esm/dispatch/notify.d.mts +1 -1
- package/esm/dispatch/notify.d.mts.map +1 -1
- package/esm/dispatch/notify.mjs +1 -1
- package/esm/dispatch/notify.mjs.map +1 -1
- package/esm/errors.d.mts +1 -1
- package/esm/errors.d.mts.map +1 -1
- package/esm/errors.mjs +1 -1
- package/esm/errors.mjs.map +1 -1
- package/esm/in-app/base-notifications-repository.d.mts +1 -1
- package/esm/in-app/base-notifications-repository.d.mts.map +1 -1
- package/esm/in-app/base-notifications-repository.mjs +1 -1
- package/esm/in-app/base-notifications-repository.mjs.map +1 -1
- package/esm/in-app/column-map.d.mts +1 -1
- package/esm/in-app/column-map.d.mts.map +1 -1
- package/esm/in-app/column-map.mjs +1 -1
- package/esm/in-app/column-map.mjs.map +1 -1
- package/esm/in-app/database-notification.d.mts +1 -1
- package/esm/in-app/database-notification.d.mts.map +1 -1
- package/esm/in-app/database-notification.mjs +1 -1
- package/esm/in-app/database-notification.mjs.map +1 -1
- package/esm/in-app/in-app.d.mts +1 -1
- package/esm/in-app/in-app.d.mts.map +1 -1
- package/esm/in-app/in-app.mjs +1 -1
- package/esm/in-app/in-app.mjs.map +1 -1
- package/esm/migration/notification-columns.d.mts +1 -1
- package/esm/migration/notification-columns.d.mts.map +1 -1
- package/esm/migration/notification-columns.mjs +1 -1
- package/esm/migration/notification-columns.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/_internal.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/_internal.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/mixed/clone/clone.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/mixed/clone/clone.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/number/round.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/number/round.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/except.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/except.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/get.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/get.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/omit.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/omit.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/unset.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/unset.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/capitalize.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/capitalize.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ltrim.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ltrim.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/readMoreChars.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/readMoreChars.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/rtrim.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/rtrim.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toCamelCase.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toCamelCase.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toKebabCase.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toKebabCase.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toSnakeCase.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toSnakeCase.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toStudlyCase.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toStudlyCase.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/trim.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/trim.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ucfirst.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ucfirst.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/words.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/words.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/escapeRegex.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/escapeRegex.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/lazy.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/lazy.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/tap.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/tap.mjs.map +1 -1
- package/esm/node_modules/.pnpm/@mongez_supportive-is@3.0.0/node_modules/@mongez/supportive-is/esm/index.mjs +1 -1
- package/esm/node_modules/.pnpm/@mongez_supportive-is@3.0.0/node_modules/@mongez/supportive-is/esm/index.mjs.map +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/channel_api.mjs +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/channel_api.mjs.map +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/api_args.mjs +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/api_args.mjs.map +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/bitset.mjs +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/bitset.mjs.map +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/channel.mjs +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/channel.mjs.map +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/channel_model.mjs +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/channel_model.mjs.map +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/codec.mjs +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/codec.mjs.map +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/connect.mjs +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/connect.mjs.map +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/connection.mjs +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/connection.mjs.map +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/credentials.mjs +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/credentials.mjs.map +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/defs.mjs +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/defs.mjs.map +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/error.mjs +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/error.mjs.map +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/format.mjs +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/format.mjs.map +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/frame.mjs +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/frame.mjs.map +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/heartbeat.mjs +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/heartbeat.mjs.map +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/mux.mjs +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/mux.mjs.map +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/package.mjs +1 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/package.mjs.map +1 -1
- package/esm/node_modules/.pnpm/buffer-more-ints@1.0.0/node_modules/buffer-more-ints/buffer-more-ints.mjs +1 -1
- package/esm/node_modules/.pnpm/buffer-more-ints@1.0.0/node_modules/buffer-more-ints/buffer-more-ints.mjs.map +1 -1
- package/esm/node_modules/.pnpm/dayjs@1.11.23/node_modules/dayjs/dayjs.min.mjs +1 -1
- package/esm/node_modules/.pnpm/dayjs@1.11.23/node_modules/dayjs/dayjs.min.mjs.map +1 -1
- package/esm/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.mjs +1 -1
- package/esm/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.mjs.map +1 -1
- package/esm/node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.mjs +1 -1
- package/esm/node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.mjs.map +1 -1
- package/esm/node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.mjs +1 -1
- package/esm/node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.mjs.map +1 -1
- package/esm/{herald → packages/herald}/src/communicators/broker-registry.mjs +1 -1
- package/esm/packages/herald/src/communicators/broker-registry.mjs.map +1 -0
- package/esm/{herald → packages/herald}/src/communicators/broker.mjs +1 -1
- package/esm/packages/herald/src/communicators/broker.mjs.map +1 -0
- package/esm/{herald → packages/herald}/src/decorators/consumable.mjs +1 -1
- package/esm/packages/herald/src/decorators/consumable.mjs.map +1 -0
- package/esm/{herald → packages/herald}/src/drivers/rabbitmq/rabbitmq-channel.mjs +1 -1
- package/esm/packages/herald/src/drivers/rabbitmq/rabbitmq-channel.mjs.map +1 -0
- package/esm/{herald → packages/herald}/src/drivers/rabbitmq/rabbitmq-driver.mjs +3 -3
- package/esm/packages/herald/src/drivers/rabbitmq/rabbitmq-driver.mjs.map +1 -0
- package/esm/{herald → packages/herald}/src/message-managers/event-consumer.mjs +1 -1
- package/esm/packages/herald/src/message-managers/event-consumer.mjs.map +1 -0
- package/esm/{herald → packages/herald}/src/message-managers/event-message.mjs +1 -1
- package/esm/packages/herald/src/message-managers/event-message.mjs.map +1 -0
- package/esm/{herald → packages/herald}/src/message-managers/prepare-consumer-subscription.mjs +1 -1
- package/esm/packages/herald/src/message-managers/prepare-consumer-subscription.mjs.map +1 -0
- package/esm/{herald → packages/herald}/src/use-case-broadcast.mjs +1 -1
- package/esm/packages/herald/src/use-case-broadcast.mjs.map +1 -0
- package/esm/{herald → packages/herald}/src/utils/connect-to-broker.mjs +1 -1
- package/esm/packages/herald/src/utils/connect-to-broker.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/config.mjs +1 -1
- package/esm/packages/seal/src/config.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/factory/validate.mjs +12 -4
- package/esm/packages/seal/src/factory/validate.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/factory/validators.mjs +1 -1
- package/esm/packages/seal/src/factory/validators.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/helpers/date-helpers.mjs +1 -1
- package/esm/packages/seal/src/helpers/date-helpers.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/helpers/get-field-value.mjs +3 -3
- package/esm/packages/seal/src/helpers/get-field-value.mjs.map +1 -0
- package/esm/packages/seal/src/helpers/is-empty-value.mjs +10 -0
- package/esm/packages/seal/src/helpers/is-empty-value.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/helpers/path-helpers.mjs +1 -1
- package/esm/packages/seal/src/helpers/path-helpers.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/helpers/validation-helpers.mjs +1 -1
- package/esm/packages/seal/src/helpers/validation-helpers.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/mutators/array-mutators.mjs +3 -3
- package/esm/packages/seal/src/mutators/array-mutators.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/mutators/boolean-mutators.mjs +1 -1
- package/esm/packages/seal/src/mutators/boolean-mutators.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/mutators/date-mutators.mjs +3 -3
- package/esm/packages/seal/src/mutators/date-mutators.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/mutators/number-mutators.mjs +4 -4
- package/esm/packages/seal/src/mutators/number-mutators.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/mutators/object-mutators.mjs +4 -4
- package/esm/packages/seal/src/mutators/object-mutators.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/mutators/scalar-mutators.mjs +1 -1
- package/esm/packages/seal/src/mutators/scalar-mutators.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/mutators/string-mutators.mjs +11 -11
- package/esm/packages/seal/src/mutators/string-mutators.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/object.mjs +1 -1
- package/esm/packages/seal/src/object.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/array/array-rules.mjs +1 -1
- package/esm/packages/seal/src/rules/array/array-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/color/color-rules.mjs +1 -1
- package/esm/packages/seal/src/rules/color/color-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/common/enum.mjs +1 -1
- package/esm/packages/seal/src/rules/common/enum.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/common/equals-field-rules.mjs +1 -1
- package/esm/packages/seal/src/rules/common/equals-field-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/common/instanceof.mjs +1 -1
- package/esm/packages/seal/src/rules/common/instanceof.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/common/literal.mjs +1 -1
- package/esm/packages/seal/src/rules/common/literal.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/common/type-rules.mjs +2 -2
- package/esm/packages/seal/src/rules/common/type-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/common/unknown-key.mjs +1 -1
- package/esm/packages/seal/src/rules/common/unknown-key.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/conditional/forbidden-if-rules.mjs +1 -1
- package/esm/packages/seal/src/rules/conditional/forbidden-if-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/conditional/present-if-rules.mjs +1 -1
- package/esm/packages/seal/src/rules/conditional/present-if-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/conditional/present-unless-rules.mjs +1 -1
- package/esm/packages/seal/src/rules/conditional/present-unless-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/conditional/present-with-rules.mjs +3 -3
- package/esm/packages/seal/src/rules/conditional/present-with-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/conditional/present-without-rules.mjs +3 -3
- package/esm/packages/seal/src/rules/conditional/present-without-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/conditional/required-if-rules.mjs +3 -3
- package/esm/packages/seal/src/rules/conditional/required-if-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/conditional/required-unless-rules.mjs +1 -1
- package/esm/packages/seal/src/rules/conditional/required-unless-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/conditional/required-when-rule.mjs +1 -1
- package/esm/packages/seal/src/rules/conditional/required-when-rule.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/conditional/required-with-rules.mjs +3 -3
- package/esm/packages/seal/src/rules/conditional/required-with-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/conditional/required-without-rules.mjs +3 -3
- package/esm/packages/seal/src/rules/conditional/required-without-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/core/equal.mjs +1 -1
- package/esm/packages/seal/src/rules/core/equal.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/core/forbidden.mjs +1 -1
- package/esm/packages/seal/src/rules/core/forbidden.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/core/required.mjs +1 -1
- package/esm/packages/seal/src/rules/core/required.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/core/union.mjs +3 -1
- package/esm/packages/seal/src/rules/core/union.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/core/when.mjs +3 -3
- package/esm/packages/seal/src/rules/core/when.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/date/date-comparison-rules.mjs +1 -1
- package/esm/packages/seal/src/rules/date/date-comparison-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/date/date-day-rules.mjs +1 -1
- package/esm/packages/seal/src/rules/date/date-day-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/date/date-field-comparison-rules.mjs +3 -3
- package/esm/packages/seal/src/rules/date/date-field-comparison-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/date/date-period-rules.mjs +3 -3
- package/esm/packages/seal/src/rules/date/date-period-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/date/date-relative-rules.mjs +1 -1
- package/esm/packages/seal/src/rules/date/date-relative-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/date/date-special-rules.mjs +1 -1
- package/esm/packages/seal/src/rules/date/date-special-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/date/date.mjs +3 -3
- package/esm/packages/seal/src/rules/date/date.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/length/length-rules.mjs +1 -1
- package/esm/packages/seal/src/rules/length/length-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/number/number-rules.mjs +3 -3
- package/esm/packages/seal/src/rules/number/number-rules.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/scalar/accepted-rule.mjs +1 -1
- package/esm/packages/seal/src/rules/scalar/accepted-rule.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/scalar/declined-rule.mjs +1 -1
- package/esm/packages/seal/src/rules/scalar/declined-rule.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/string/alpha.mjs +1 -1
- package/esm/packages/seal/src/rules/string/alpha.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/string/credit-card.mjs +1 -1
- package/esm/packages/seal/src/rules/string/credit-card.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/string/email.mjs +2 -2
- package/esm/packages/seal/src/rules/string/email.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/string/id-formats.mjs +1 -1
- package/esm/packages/seal/src/rules/string/id-formats.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/string/ip.mjs +1 -1
- package/esm/packages/seal/src/rules/string/ip.mjs.map +1 -0
- package/esm/packages/seal/src/rules/string/matches.mjs +4 -0
- package/esm/{seal → packages/seal}/src/rules/string/pattern.mjs +1 -1
- package/esm/packages/seal/src/rules/string/pattern.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/string/string-comparison.mjs +1 -1
- package/esm/packages/seal/src/rules/string/string-comparison.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/string/strong-password-rule.mjs +1 -1
- package/esm/packages/seal/src/rules/string/strong-password-rule.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/string/url.mjs +1 -1
- package/esm/packages/seal/src/rules/string/url.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/rules/string/without-whitespace.mjs +1 -1
- package/esm/packages/seal/src/rules/string/without-whitespace.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/standard-schema/json-schema.mjs +1 -1
- package/esm/packages/seal/src/standard-schema/json-schema.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/standard-schema/map-result.mjs +1 -1
- package/esm/packages/seal/src/standard-schema/map-result.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/string.mjs +1 -1
- package/esm/packages/seal/src/string.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/types/date-types.mjs +1 -1
- package/esm/packages/seal/src/types/date-types.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/any-validator.mjs +1 -1
- package/esm/packages/seal/src/validators/any-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/array-validator.mjs +1 -1
- package/esm/packages/seal/src/validators/array-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/base-validator.mjs +25 -6
- package/esm/packages/seal/src/validators/base-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/boolean-validator.mjs +1 -1
- package/esm/packages/seal/src/validators/boolean-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/computed-validator.mjs +1 -1
- package/esm/packages/seal/src/validators/computed-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/date-validator.mjs +3 -3
- package/esm/packages/seal/src/validators/date-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/discriminated-union-validator.mjs +7 -2
- package/esm/packages/seal/src/validators/discriminated-union-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/float-validator.mjs +1 -1
- package/esm/packages/seal/src/validators/float-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/instanceof-validator.mjs +1 -1
- package/esm/packages/seal/src/validators/instanceof-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/int-validator.mjs +1 -1
- package/esm/packages/seal/src/validators/int-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/lazy-validator.mjs +1 -1
- package/esm/packages/seal/src/validators/lazy-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/literal-validator.mjs +5 -2
- package/esm/packages/seal/src/validators/literal-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/managed-validator.mjs +1 -1
- package/esm/packages/seal/src/validators/managed-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/methods/equality-conditional-methods.mjs +1 -1
- package/esm/packages/seal/src/validators/methods/equality-conditional-methods.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/methods/forbidden-methods.mjs +1 -1
- package/esm/packages/seal/src/validators/methods/forbidden-methods.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/methods/present-methods.mjs +1 -1
- package/esm/packages/seal/src/validators/methods/present-methods.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/methods/required-methods.mjs +1 -1
- package/esm/packages/seal/src/validators/methods/required-methods.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/number-validator.mjs +1 -1
- package/esm/packages/seal/src/validators/number-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/numeric-validator.mjs +2 -2
- package/esm/packages/seal/src/validators/numeric-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/object-validator.mjs +8 -6
- package/esm/packages/seal/src/validators/object-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/primitive-validator.mjs +1 -1
- package/esm/packages/seal/src/validators/primitive-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/record-validator.mjs +2 -2
- package/esm/packages/seal/src/validators/record-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/scalar-validator.mjs +1 -1
- package/esm/packages/seal/src/validators/scalar-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/string-validator.mjs +1 -1
- package/esm/packages/seal/src/validators/string-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/tuple-validator.mjs +1 -1
- package/esm/packages/seal/src/validators/tuple-validator.mjs.map +1 -0
- package/esm/{seal → packages/seal}/src/validators/union-validator.mjs +1 -1
- package/esm/packages/seal/src/validators/union-validator.mjs.map +1 -0
- package/esm/queue/bullmq-queue.d.mts +1 -1
- package/esm/queue/bullmq-queue.d.mts.map +1 -1
- package/esm/queue/bullmq-queue.mjs +1 -1
- package/esm/queue/bullmq-queue.mjs.map +1 -1
- package/esm/queue/herald-queue.d.mts +1 -1
- package/esm/queue/herald-queue.d.mts.map +1 -1
- package/esm/queue/herald-queue.mjs +1 -1
- package/esm/queue/herald-queue.mjs.map +1 -1
- package/esm/queue/load-herald.d.mts +1 -1
- package/esm/queue/load-herald.d.mts.map +1 -1
- package/esm/queue/load-herald.mjs +2 -2
- package/esm/queue/load-herald.mjs.map +1 -1
- package/esm/queue/load-queue.d.mts +1 -1
- package/esm/queue/load-queue.d.mts.map +1 -1
- package/esm/queue/load-queue.mjs +1 -1
- package/esm/queue/load-queue.mjs.map +1 -1
- package/esm/queue/notifications-worker.d.mts +1 -1
- package/esm/queue/notifications-worker.d.mts.map +1 -1
- package/esm/queue/notifications-worker.mjs +1 -1
- package/esm/queue/notifications-worker.mjs.map +1 -1
- package/esm/queue/queue-package-not-installed.error.d.mts +1 -1
- package/esm/queue/queue-package-not-installed.error.d.mts.map +1 -1
- package/esm/queue/queue-package-not-installed.error.mjs +1 -1
- package/esm/queue/queue-package-not-installed.error.mjs.map +1 -1
- package/esm/types.d.mts +1 -1
- package/esm/types.d.mts.map +1 -1
- package/llms-full.txt +57 -57
- package/llms.txt +8 -8
- package/package.json +9 -8
- package/skills/configure-notifications/SKILL.md +6 -6
- package/skills/define-channel/SKILL.md +6 -6
- package/skills/define-notification/SKILL.md +5 -5
- package/skills/notifications-basics/SKILL.md +8 -8
- package/skills/observe-notifications/SKILL.md +4 -4
- package/skills/queue-notifications/SKILL.md +5 -5
- package/skills/send-ad-hoc/SKILL.md +8 -8
- package/skills/use-in-app/SKILL.md +8 -8
- package/skills/write-notification-migration/SKILL.md +7 -7
- package/cjs/channel_api-CBB_XoIl.cjs.map +0 -1
- package/cjs/rabbitmq-driver-CYeFwv0w.cjs +0 -3
- package/cjs/src-B6UVThgW.cjs.map +0 -1
- package/esm/herald/src/communicators/broker-registry.mjs.map +0 -1
- package/esm/herald/src/communicators/broker.mjs.map +0 -1
- package/esm/herald/src/decorators/consumable.mjs.map +0 -1
- package/esm/herald/src/drivers/rabbitmq/rabbitmq-channel.mjs.map +0 -1
- package/esm/herald/src/drivers/rabbitmq/rabbitmq-driver.mjs.map +0 -1
- package/esm/herald/src/message-managers/event-consumer.mjs.map +0 -1
- package/esm/herald/src/message-managers/event-message.mjs.map +0 -1
- package/esm/herald/src/message-managers/prepare-consumer-subscription.mjs.map +0 -1
- package/esm/herald/src/use-case-broadcast.mjs.map +0 -1
- package/esm/herald/src/utils/connect-to-broker.mjs.map +0 -1
- package/esm/seal/src/config.mjs.map +0 -1
- package/esm/seal/src/factory/validate.mjs.map +0 -1
- package/esm/seal/src/factory/validators.mjs.map +0 -1
- package/esm/seal/src/helpers/date-helpers.mjs.map +0 -1
- package/esm/seal/src/helpers/get-field-value.mjs.map +0 -1
- package/esm/seal/src/helpers/is-empty-value.mjs +0 -10
- package/esm/seal/src/helpers/is-empty-value.mjs.map +0 -1
- package/esm/seal/src/helpers/path-helpers.mjs.map +0 -1
- package/esm/seal/src/helpers/validation-helpers.mjs.map +0 -1
- package/esm/seal/src/mutators/array-mutators.mjs.map +0 -1
- package/esm/seal/src/mutators/boolean-mutators.mjs.map +0 -1
- package/esm/seal/src/mutators/date-mutators.mjs.map +0 -1
- package/esm/seal/src/mutators/number-mutators.mjs.map +0 -1
- package/esm/seal/src/mutators/object-mutators.mjs.map +0 -1
- package/esm/seal/src/mutators/scalar-mutators.mjs.map +0 -1
- package/esm/seal/src/mutators/string-mutators.mjs.map +0 -1
- package/esm/seal/src/object.mjs.map +0 -1
- package/esm/seal/src/rules/array/array-rules.mjs.map +0 -1
- package/esm/seal/src/rules/color/color-rules.mjs.map +0 -1
- package/esm/seal/src/rules/common/enum.mjs.map +0 -1
- package/esm/seal/src/rules/common/equals-field-rules.mjs.map +0 -1
- package/esm/seal/src/rules/common/instanceof.mjs.map +0 -1
- package/esm/seal/src/rules/common/literal.mjs.map +0 -1
- package/esm/seal/src/rules/common/type-rules.mjs.map +0 -1
- package/esm/seal/src/rules/common/unknown-key.mjs.map +0 -1
- package/esm/seal/src/rules/conditional/forbidden-if-rules.mjs.map +0 -1
- package/esm/seal/src/rules/conditional/present-if-rules.mjs.map +0 -1
- package/esm/seal/src/rules/conditional/present-unless-rules.mjs.map +0 -1
- package/esm/seal/src/rules/conditional/present-with-rules.mjs.map +0 -1
- package/esm/seal/src/rules/conditional/present-without-rules.mjs.map +0 -1
- package/esm/seal/src/rules/conditional/required-if-rules.mjs.map +0 -1
- package/esm/seal/src/rules/conditional/required-unless-rules.mjs.map +0 -1
- package/esm/seal/src/rules/conditional/required-when-rule.mjs.map +0 -1
- package/esm/seal/src/rules/conditional/required-with-rules.mjs.map +0 -1
- package/esm/seal/src/rules/conditional/required-without-rules.mjs.map +0 -1
- package/esm/seal/src/rules/core/equal.mjs.map +0 -1
- package/esm/seal/src/rules/core/forbidden.mjs.map +0 -1
- package/esm/seal/src/rules/core/required.mjs.map +0 -1
- package/esm/seal/src/rules/core/union.mjs.map +0 -1
- package/esm/seal/src/rules/core/when.mjs.map +0 -1
- package/esm/seal/src/rules/date/date-comparison-rules.mjs.map +0 -1
- package/esm/seal/src/rules/date/date-day-rules.mjs.map +0 -1
- package/esm/seal/src/rules/date/date-field-comparison-rules.mjs.map +0 -1
- package/esm/seal/src/rules/date/date-period-rules.mjs.map +0 -1
- package/esm/seal/src/rules/date/date-relative-rules.mjs.map +0 -1
- package/esm/seal/src/rules/date/date-special-rules.mjs.map +0 -1
- package/esm/seal/src/rules/date/date.mjs.map +0 -1
- package/esm/seal/src/rules/length/length-rules.mjs.map +0 -1
- package/esm/seal/src/rules/number/number-rules.mjs.map +0 -1
- package/esm/seal/src/rules/scalar/accepted-rule.mjs.map +0 -1
- package/esm/seal/src/rules/scalar/declined-rule.mjs.map +0 -1
- package/esm/seal/src/rules/string/alpha.mjs.map +0 -1
- package/esm/seal/src/rules/string/credit-card.mjs.map +0 -1
- package/esm/seal/src/rules/string/email.mjs.map +0 -1
- package/esm/seal/src/rules/string/id-formats.mjs.map +0 -1
- package/esm/seal/src/rules/string/ip.mjs.map +0 -1
- package/esm/seal/src/rules/string/matches.mjs +0 -4
- package/esm/seal/src/rules/string/pattern.mjs.map +0 -1
- package/esm/seal/src/rules/string/string-comparison.mjs.map +0 -1
- package/esm/seal/src/rules/string/strong-password-rule.mjs.map +0 -1
- package/esm/seal/src/rules/string/url.mjs.map +0 -1
- package/esm/seal/src/rules/string/without-whitespace.mjs.map +0 -1
- package/esm/seal/src/standard-schema/json-schema.mjs.map +0 -1
- package/esm/seal/src/standard-schema/map-result.mjs.map +0 -1
- package/esm/seal/src/string.mjs.map +0 -1
- package/esm/seal/src/types/date-types.mjs.map +0 -1
- package/esm/seal/src/validators/any-validator.mjs.map +0 -1
- package/esm/seal/src/validators/array-validator.mjs.map +0 -1
- package/esm/seal/src/validators/base-validator.mjs.map +0 -1
- package/esm/seal/src/validators/boolean-validator.mjs.map +0 -1
- package/esm/seal/src/validators/computed-validator.mjs.map +0 -1
- package/esm/seal/src/validators/date-validator.mjs.map +0 -1
- package/esm/seal/src/validators/discriminated-union-validator.mjs.map +0 -1
- package/esm/seal/src/validators/float-validator.mjs.map +0 -1
- package/esm/seal/src/validators/instanceof-validator.mjs.map +0 -1
- package/esm/seal/src/validators/int-validator.mjs.map +0 -1
- package/esm/seal/src/validators/lazy-validator.mjs.map +0 -1
- package/esm/seal/src/validators/literal-validator.mjs.map +0 -1
- package/esm/seal/src/validators/managed-validator.mjs.map +0 -1
- package/esm/seal/src/validators/methods/equality-conditional-methods.mjs.map +0 -1
- package/esm/seal/src/validators/methods/forbidden-methods.mjs.map +0 -1
- package/esm/seal/src/validators/methods/present-methods.mjs.map +0 -1
- package/esm/seal/src/validators/methods/required-methods.mjs.map +0 -1
- package/esm/seal/src/validators/number-validator.mjs.map +0 -1
- package/esm/seal/src/validators/numeric-validator.mjs.map +0 -1
- package/esm/seal/src/validators/object-validator.mjs.map +0 -1
- package/esm/seal/src/validators/primitive-validator.mjs.map +0 -1
- package/esm/seal/src/validators/record-validator.mjs.map +0 -1
- package/esm/seal/src/validators/scalar-validator.mjs.map +0 -1
- package/esm/seal/src/validators/string-validator.mjs.map +0 -1
- package/esm/seal/src/validators/tuple-validator.mjs.map +0 -1
- package/esm/seal/src/validators/union-validator.mjs.map +0 -1
- /package/esm/{herald → packages/herald}/src/communicators/index.mjs +0 -0
- /package/esm/{herald → packages/herald}/src/decorators/index.mjs +0 -0
- /package/esm/{herald → packages/herald}/src/drivers/index.mjs +0 -0
- /package/esm/{herald → packages/herald}/src/drivers/rabbitmq/index.mjs +0 -0
- /package/esm/{herald → packages/herald}/src/index.mjs +0 -0
- /package/esm/{herald → packages/herald}/src/message-managers/index.mjs +0 -0
- /package/esm/{herald → packages/herald}/src/utils/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/factory/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/helpers/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/mutators/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/rules/array/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/rules/color/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/rules/common/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/rules/conditional/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/rules/core/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/rules/date/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/rules/file/dimensions.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/rules/file/file-size.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/rules/file/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/rules/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/rules/length/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/rules/number/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/rules/scalar/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/rules/string/index.mjs +0 -0
- /package/esm/{seal → packages/seal}/src/validators/index.mjs +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-validator.mjs","names":["defaultRequiredRule"],"sources":["../../../../../../../../../seal/src/validators/base-validator.ts"],"sourcesContent":["import { clone } from \"@mongez/reinforcements\";\nimport { validate } from \"../factory/validate\";\nimport { VALID_RULE, invalidRule } from \"../helpers/validation-helpers\";\nimport { isEmptyValue } from \"../helpers/is-empty-value\";\nimport { requiredRule as defaultRequiredRule } from \"../rules/core/required\";\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\nimport { mapToStandardResult } from \"../standard-schema/map-result\";\nimport type { StandardJSONSchemaV1, StandardSchemaV1 } from \"../standard-schema/types\";\nimport type {\n ContextualSchemaRule,\n ContextualizedMutator,\n ContextualizedTransformer,\n Mutator,\n SchemaContext,\n SchemaRule,\n SchemaRuleOptions,\n SimpleTransformerCallback,\n TransformerCallback,\n ValidationAttributesList,\n ValidationResult,\n} from \"../types\";\n\n/**\n * Base validator class - foundation for all validators\n */\nexport class BaseValidator<TInput = unknown, TOutput = TInput> {\n public rules: ContextualSchemaRule[] = [];\n public mutators: ContextualizedMutator[] = [];\n protected defaultValue: any | (() => any);\n protected description?: string;\n protected shouldOmit = false;\n protected isNullable = false;\n protected isMutable = false;\n /** Treat empty or whitespace-only form strings as an absent value. */\n protected blankIsMissing = false;\n\n /**\n * Catch state — when `hasCatch` is true and validation fails, `catchValue`\n * (or its callback result) substitutes for the failed value, and the public\n * result reports `isValid: true` with no errors.\n *\n * See `.catch()` for semantics and the v1 scope (leaf-only).\n */\n protected catchValue:\n any | ((errors: ValidationResult[\"errors\"], originalInput: any) => any | Promise<any>);\n protected hasCatch = false;\n\n /**\n * Whether the field is optional.\n * - false (default): field is required unless a requiredRule governs the condition.\n * - true: field can be absent or empty — set by calling .optional().\n *\n * Also used as a TypeScript literal brand via the optional() return type.\n */\n public isOptional = false;\n\n /**\n * The single required-condition rule for this field.\n * - null: field uses strict default (always required when not optional).\n * - set: the rule governs when the field is required (e.g., requiredIf).\n *\n * Stored separately from rules[] and prepended at validate() time.\n */\n public requiredRule: ContextualSchemaRule | null = this.createRule(defaultRequiredRule);\n\n /**\n * Pipeline to transform the mutated/original data before returning it\n */\n protected dataTransformers: ContextualizedTransformer[] = [];\n\n /**\n * Attributes text to be replaced on translations\n * If the value is an object, it will be used as the attributes list for the rule\n * If the value is a string, it will be used as the attributes list for the rule\n */\n protected attributesText: ValidationAttributesList = {};\n\n /**\n * Attributed that will be always using the attribute translator\n */\n protected translatedAttributes: Record<string, string> = {};\n\n /**\n * Mark the validator as mutable\n */\n public get mutable() {\n this.isMutable = true;\n return this;\n }\n\n /**\n * Mark the validator as immutable\n */\n public get immutable() {\n this.isMutable = false;\n return this;\n }\n\n /**\n * Get the instance to apply changes to.\n * By default (immutable), returns a clone so the original is unchanged.\n * When `.mutable` is set, returns `this` to mutate in place.\n */\n protected get instance(): this {\n return this.isMutable ? this : this.clone();\n }\n\n /**\n * Get the default value\n * Supports lazy evaluation via callbacks\n */\n public getDefaultValue(): any {\n return typeof this.defaultValue === \"function\" ? this.defaultValue() : this.defaultValue;\n }\n\n /**\n * Allow null as a valid value.\n *\n * Brands the return type with `{ isNullable: true }` so `Infer<>` widens\n * the inferred output to include `| null`.\n */\n public nullable(): this & { isNullable: true } {\n const instance = this.instance;\n instance.isNullable = true;\n return instance as this & { isNullable: true };\n }\n\n /**\n * Explicitly disallow null values after calling nullable.\n *\n * Brands the return type with `{ isNullable: false }` to cancel any prior\n * `.nullable()` at the type level.\n */\n public notNullable(): this & { isNullable: false } {\n const instance = this.instance;\n instance.isNullable = false;\n return instance as this & { isNullable: false };\n }\n\n /**\n * Add transformer with optional options\n *\n * @param transform - The transformer callback function\n * @param options - Optional options to pass to the transformer\n *\n * @example\n * ```ts\n * // Without options\n * v.date().addTransformer(data => data.toISOString())\n *\n * // With options\n * v.date().addTransformer(\n * (data, { options }) => dayjs(data).format(options.format),\n * { format: 'YYYY-MM-DD' }\n * )\n * ```\n */\n public addTransformer(transform: TransformerCallback, options: any = {}) {\n const instance = this.instance;\n instance.addMutableTransformer(transform, options);\n\n return instance;\n }\n\n /**\n * Add transformer with optional options\n *\n * @param transform - The transformer callback function\n * @param options - Optional options to pass to the transformer\n *\n * @example\n * ```ts\n * // Without options\n * v.date().addTransformer(data => data.toISOString())\n *\n * // With options\n * v.date().addTransformer(\n * (data, { options }) => dayjs(data).format(options.format),\n * { format: 'YYYY-MM-DD' }\n * )\n * ```\n */\n public addMutableTransformer(transform: TransformerCallback, options: any = {}) {\n this.dataTransformers.push({\n transform,\n options,\n });\n }\n\n /**\n * Transform the output value - simple one-time transformation\n *\n * @param callback - Simple callback receiving data and context\n *\n * @example\n * ```ts\n * // Simple transformation\n * v.string().outputAs(data => data.toUpperCase())\n *\n * // With context\n * v.string().outputAs((data, context) => {\n * console.log(`Transforming ${context.path}`);\n * return data.toLowerCase();\n * })\n * ```\n */\n public outputAs(callback: SimpleTransformerCallback) {\n return this.addTransformer((data, { context }) => callback(data, context));\n }\n\n /**\n * Transform output to JSON string\n *\n * Works with any validator type (string, number, date, object, array, etc.)\n *\n * @param indent - Optional indentation for pretty printing (default: 0 for compact)\n *\n * @example\n * ```ts\n * // Compact JSON\n * v.object({ name: v.string() }).toJSON()\n * // Output: '{\"name\":\"John\"}'\n *\n * // Pretty-printed JSON\n * v.array(v.object({...})).toJSON(2)\n * // Output:\n * // [\n * // {\n * // \"name\": \"John\"\n * // }\n * // ]\n *\n * // Works with any type\n * v.string().toJSON() // '\"hello\"'\n * v.number().toJSON() // '42'\n * v.date().toJSON() // '\"2024-10-26T00:00:00.000Z\"'\n * ```\n *\n * @category Transformer\n */\n public toJSON(indent?: number) {\n return this.addTransformer((data, { options }) => JSON.stringify(data, null, options.indent), {\n indent: indent ?? 0,\n });\n }\n\n /**\n * Start data transformation pipeline\n * Context is passed at runtime, not stored\n */\n public async startTransformationPipeline(data: any, context: SchemaContext) {\n for (const transformer of this.dataTransformers) {\n data = await transformer.transform(data, {\n options: transformer.options,\n context,\n });\n }\n\n return data;\n }\n\n /**\n * Set attributes text to be replaced on translations\n * If the value is an object, it will be used as the attributes list for the rule\n * If the value is a string, it will be used as the attributes list for the rule\n *\n * @example\n * v.string().attributes({\n * name: \"Name\",\n * email: \"Email\",\n * });\n * // Example 2: Add custom attributes for matches\n * v.string().matches(\"confirmPassword\").attributes({\n * matches: {\n * confirmPassword: \"Confirm Password\",\n * },\n * });\n */\n public attributes(attributes: Record<string, string | Record<string, string>>) {\n const instance = this.instance;\n for (const [key, value] of Object.entries(attributes)) {\n instance.attributesText[key] = value;\n }\n\n return instance;\n }\n\n /**\n * Define a lazy getter property for each attribute in the given object and use the config attribute translator\n */\n public transAttributes(attributes: Record<string, string>) {\n const instance = this.instance;\n for (const [key, value] of Object.entries(attributes)) {\n instance.translatedAttributes[key] = value;\n }\n\n return instance;\n }\n\n /**\n * Add description to the validator\n */\n public describe(description: string) {\n const instance = this.instance;\n instance.description = description;\n return instance;\n }\n\n /**\n * Check if this validator can handle the given value's type\n * Override this in specific validators to enable type-based routing in union validators\n *\n * Default: returns true (validator will attempt to validate any type)\n *\n * @param value - The value to check\n * @returns True if this validator can handle this type\n *\n * @example\n * ```ts\n * // StringValidator\n * public matchesType(value: any): boolean {\n * return typeof value === 'string';\n * }\n *\n * // Custom FileValidator\n * public matchesType(value: any): boolean {\n * return value instanceof UploadedFile;\n * }\n * ```\n */\n public matchesType(_value: any): boolean {\n return true; // Default: permissive, attempt to validate any type\n }\n\n /**\n * Create a copy of this validator with the same configuration\n * Copies all rules, mutators, transformers, default values, and settings\n *\n * @returns A new validator instance with copied configuration\n *\n * @example\n * ```ts\n * // Create reusable validator templates\n * const baseString = v.string().required().trim().min(3);\n * const emailField = baseString.clone().email();\n * const usernameField = baseString.clone().alphanumeric().max(20);\n *\n * // Works with all validators\n * const positiveInt = v.int().positive().required();\n * const ageField = positiveInt.clone().min(18).max(120);\n * ```\n */\n public clone(): this {\n // Create a new instance using Object.create to preserve the prototype chain\n const Constructor = this.constructor as new (...args: any[]) => this;\n const cloned = Object.create(Constructor.prototype);\n\n // Copy all BaseValidator properties\n cloned.rules = [...this.rules];\n cloned.mutators = [...this.mutators];\n cloned.dataTransformers = [...this.dataTransformers];\n cloned.defaultValue = this.defaultValue;\n cloned.shouldOmit = this.shouldOmit;\n cloned.description = this.description;\n cloned.attributesText = { ...this.attributesText };\n cloned.translatedAttributes = { ...this.translatedAttributes };\n cloned.isNullable = this.isNullable;\n cloned.isOptional = this.isOptional;\n cloned.blankIsMissing = this.blankIsMissing;\n cloned.requiredRule = this.requiredRule; // same reference is fine — rule is treated as immutable\n cloned.catchValue = this.catchValue;\n cloned.hasCatch = this.hasCatch;\n\n return cloned;\n }\n\n /**\n * @deprecated This method is no longer needed and does nothing.\n * Empty values are now automatically skipped for validation rules by default.\n * Only presence validators (required, present, etc.) will check empty values.\n * You can safely remove this call from your code.\n */\n public ignoreEmptyValue(_ignoreEmptyValue = true) {\n // No-op for backward compatibility\n return this;\n }\n\n /**\n * Omit this field from the validated data output\n *\n * Field will still be validated but not included in the final result.\n * Useful for confirmation fields, captcha, terms acceptance, etc.\n *\n * @example\n * ```ts\n * v.object({\n * password: v.string().required(),\n * confirmPassword: v.string().required().sameAs(\"password\").omit(),\n * acceptTerms: v.boolean().required().omit(),\n * });\n * // Output: { password: \"...\" }\n * // confirmPassword and acceptTerms validated but omitted\n * ```\n */\n public omit() {\n const instance = this.instance;\n instance.shouldOmit = true;\n return instance;\n }\n\n /**\n * @alias omit\n */\n public exclude() {\n return this.omit();\n }\n\n /**\n * Check if this field should be omitted from the output\n */\n public isOmitted(): boolean {\n return this.shouldOmit;\n }\n\n /**\n * Add rule to the validator\n */\n public addRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n errorMessage?: string,\n options: T = {} as T,\n ): this {\n const instance = this.instance;\n instance.addMutableRule(rule, errorMessage, options);\n return instance;\n }\n\n /**\n * Set the required-condition rule for this field.\n *\n * Unlike addRule(), this does NOT push to rules[]. The rule is stored in the\n * dedicated `requiredRule` slot and is prepended to the validation pipeline\n * at runtime. Only one required rule can be active per field — this replaces\n * any previously set required rule.\n *\n * Also marks the field as not optional (isOptional = false).\n *\n * @example\n * ```ts\n * // Used internally by required(), requiredIf(), requiredWith(), etc.\n * BaseValidator.prototype.required = function(msg) {\n * return this.setRequiredRule(requiredRule, msg);\n * };\n * ```\n */\n public setRequiredRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n errorMessage?: string,\n options: T = {} as T,\n ): this {\n const instance = this.instance;\n instance.isOptional = false;\n instance.requiredRule = instance.createRule(rule, errorMessage, options);\n return instance;\n }\n\n /**\n * Add mutable rule\n */\n public addMutableRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n errorMessage?: string,\n options: T = {} as T,\n ): ContextualSchemaRule<T> {\n const newRule: ContextualSchemaRule<T> = this.createRule(rule, errorMessage, options);\n\n this.rules.push(newRule);\n\n return newRule;\n }\n\n /**\n * Create new rule\n */\n protected createRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n errorMessage?: string,\n options: T = {} as T,\n ): ContextualSchemaRule<T> {\n const newRule: ContextualSchemaRule<T> = {\n ...(clone(rule) as ContextualSchemaRule<T>),\n context: {\n errorMessage,\n options,\n attributesList: this.attributesText,\n translatedAttributes: this.translatedAttributes,\n translationParams: {},\n translatableParams: {},\n },\n };\n\n if (errorMessage) {\n newRule.errorMessage = errorMessage;\n }\n\n if (rule.sortOrder === undefined) {\n newRule.sortOrder = this.rules.length + 1;\n }\n\n return newRule;\n }\n\n /**\n * Use a custom or pre-built validation rule\n *\n * @param rule - The validation rule to apply\n * @param options - Rule options including errorMessage and any rule-specific options\n *\n * @example\n * ```ts\n * import { hexColorRule } from \"@warlock.js/seal\";\n *\n * v.string().useRule(hexColorRule, { errorMessage: \"Invalid color\" });\n * ```\n *\n * @example\n * ```ts\n * // With rule options\n * v.string().useRule(myCustomRule, {\n * customOption: true,\n * errorMessage: \"Custom validation failed\"\n * });\n * ```\n */\n public useRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n options?: T & { errorMessage?: string },\n ) {\n const { errorMessage, ...ruleOptions } = options || ({} as any);\n return this.addRule(rule, errorMessage, ruleOptions);\n }\n\n /**\n * Define custom rule\n */\n public refine(\n callback: (\n value: any,\n context: SchemaContext,\n ) => Promise<string | undefined> | string | undefined,\n ) {\n return this.addRule({\n name: \"custom\",\n async validate(value, context) {\n const result = await callback(value, context);\n if (result) {\n this.context.errorMessage = result;\n return invalidRule(this, context);\n }\n return VALID_RULE;\n },\n });\n }\n\n /**\n * Add mutator to the validator\n */\n public addMutator(mutator: Mutator, options: any = {}) {\n const instance = this.instance;\n instance.addMutableMutator(mutator, options);\n return instance;\n }\n\n /**\n * Add mutable mutator\n */\n public addMutableMutator(mutator: Mutator, options: any = {}) {\n this.mutators.push({\n mutate: mutator,\n context: {\n options,\n ctx: {} as any,\n },\n });\n }\n\n /**\n * Set default value for the field. The default is used when the input is\n * absent (`undefined`); it then flows through the rule pipeline.\n *\n * Brands the return type with `{ hasDefault: true }` so `Infer<>` treats\n * the field as guaranteed-present even when chained with `.optional()`.\n */\n public default(value: any): this & { hasDefault: true } {\n const instance = this.instance;\n instance.defaultValue = value;\n return instance as this & { hasDefault: true };\n }\n\n /**\n * Fallback to a value when validation fails.\n *\n * Complementary to `.default()`: `.default(x)` fires when input is **absent**,\n * `.catch(y)` fires when input is **present but invalid**. Combine them when\n * you want both behaviours: `.optional().default(x).catch(y)`.\n *\n * The fallback can be a value or a callback `(errors, originalInput) => fallback`.\n * The callback variant is the only side-channel for the swallowed errors —\n * use it to log/alert before the fallback substitutes.\n *\n * Brands the return type with `{ hasCatch: true }` so `Infer<>` treats the\n * field as guaranteed-present (the catch ensures a value will always exist).\n *\n * **Scope (v1).** Catch is honoured for **leaf validators** (string, number,\n * boolean, date, …) and for fields inside containers. It is a **no-op on\n * container validators themselves** (`v.object`, `v.array`, `v.record`,\n * `v.tuple`, `v.discriminatedUnion`) — those use their own iteration logic\n * that bypasses the catch hook in `BaseValidator.validate()`.\n *\n * @example\n * ```ts\n * v.int().min(0).catch(3) // bad number → 3\n * v.string().in([\"us\", \"eu\"]).catch(\"us\") // unknown enum → \"us\"\n * v.string().catch((errors, input) => {\n * console.warn(`bad user value: ${JSON.stringify(input)}`, errors);\n * return \"anonymous\";\n * })\n * ```\n */\n public catch(\n fallback:\n any | ((errors: ValidationResult[\"errors\"], originalInput: any) => any | Promise<any>),\n ): this & { hasCatch: true } {\n const instance = this.instance;\n\n instance.catchValue = fallback;\n instance.hasCatch = true;\n\n return instance as this & { hasCatch: true };\n }\n\n /**\n * Mutate the data\n */\n public async mutate(data: any, context: SchemaContext) {\n let mutatedData = data;\n\n for (const mutator of this.mutators) {\n mutator.context.ctx = context;\n mutatedData = await mutator.mutate(mutatedData, mutator.context);\n }\n\n return mutatedData;\n }\n\n /**\n * Set the label for the validator that will be matching the :input attribute\n */\n public label(label: string) {\n const instance = this.instance;\n instance.attributesText.input = label;\n return instance;\n }\n\n /**\n * Validate the data\n */\n public async validate(data: any, context: SchemaContext): Promise<ValidationResult> {\n if (data === null && this.isNullable) {\n return { isValid: true, errors: [], data: null };\n }\n\n const isBlank = this.blankIsMissing && typeof data === \"string\" && data.trim() === \"\";\n\n if (isBlank && this.isNullable) {\n return { isValid: true, errors: [], data: null };\n }\n\n const valueForRules = (isBlank ? undefined : data) ?? this.getDefaultValue();\n // Optional fields with no resolved value are absent, not values to\n // transform. Skipping here protects every mutator while still allowing\n // defaults and present values through the normal mutation pipeline.\n const mutatedData =\n this.isOptional && valueForRules === undefined\n ? undefined\n : await this.mutate(valueForRules, context);\n\n const errors: ValidationResult[\"errors\"] = [];\n let isValid = true;\n const isFirstErrorOnly = context.configurations?.firstErrorOnly ?? true;\n\n const isEmpty = isEmptyValue(valueForRules);\n\n // D8 fix (design/core-defects-found.md): for an optional field, only a\n // truly ABSENT value (`valueForRules === undefined` — the key was\n // missing, or was `null`/`undefined` and got coalesced above) may skip\n // the value rules. A PRESENT-but-empty value (e.g. `\"\"` from `?page=`)\n // must still run them, so `v.int().optional()` given `\"\"` fails instead\n // of silently handing back a string that `Infer.Output`'s\n // `number | undefined` forbids. Non-optional fields are unaffected —\n // their `requiredRule` (not nulled out by `.optional()`) already rejects\n // `\"\"` before these rules matter.\n const skipEmptyRules = this.isOptional ? valueForRules === undefined : isEmpty;\n\n // Prepend the required-condition rule if set, so it always runs first.\n // requiredRule has requiresValue = false so it runs even on empty values.\n const rulesToRun = this.requiredRule ? [this.requiredRule, ...this.rules] : this.rules;\n\n for (const rule of rulesToRun) {\n if ((rule.requiresValue ?? true) && skipEmptyRules) continue;\n\n this.setRuleAttributesList(rule);\n\n const result = await rule.validate(mutatedData, context);\n\n if (result.isValid === false) {\n isValid = false;\n errors.push({\n type: rule.name,\n error: result.error,\n input: result.path ?? context.path,\n });\n\n if (isFirstErrorOnly) {\n break;\n }\n }\n }\n\n const result: ValidationResult = {\n isValid,\n errors,\n data:\n mutatedData !== undefined\n ? await this.startTransformationPipeline(mutatedData, context)\n : undefined,\n };\n\n // Catch fallback — only on the leaf path. Container validators override\n // validate() and don't run this hook on their own outcome, so catching\n // a whole object/array/record is a no-op in v1.\n if (result.isValid === false && this.hasCatch) {\n const fallback =\n typeof this.catchValue === \"function\"\n ? await this.catchValue(result.errors, data)\n : this.catchValue;\n\n return { isValid: true, errors: [], data: fallback };\n }\n\n return result;\n }\n\n /**\n * Set rule attributes list\n */\n protected setRuleAttributesList(rule: ContextualSchemaRule) {\n rule.context.attributesList =\n typeof this.attributesText[rule.name] === \"object\"\n ? (this.attributesText[rule.name] as ValidationAttributesList)\n : this.attributesText;\n rule.context.translatedAttributes = this.translatedAttributes;\n }\n\n /**\n * Standard Schema V1 compliance.\n *\n * Allows this validator to be used with any Standard Schema-aware library\n * (OpenAI structured outputs, LangGraph, TanStack Form, Conform, Valibot adapters, etc.)\n * without extra adapters.\n *\n * Delegates to the `validate()` factory so all `configureSeal()` options\n * (translations, firstErrorOnly) are picked up automatically at call time.\n *\n * Includes Standard JSON Schema support via `jsonSchema.input()` / `jsonSchema.output()`.\n *\n * ## How Standard Schema libraries consume this\n *\n * You pass the **schema object itself** to the library — they internally read\n * `schema[\"~standard\"]`. Do NOT pass `schema[\"~standard\"]` directly.\n *\n * @example\n * ```ts\n * const schema = v.object({ name: v.string().required() });\n *\n * // TanStack Form — pass schema, library reads [\"~standard\"] internally\n * const form = useForm({ validators: { onChange: schema } });\n *\n * // Conform (Remix) — same pattern\n * const [form] = useForm({ onValidate({ formData }) {\n * return parseWithStandardSchema(formData, { schema });\n * }});\n *\n * // Direct validation (lower level — most apps don't need this)\n * const result = await schema[\"~standard\"].validate({ name: \"Hasan\" });\n * // → { value: { name: \"Hasan\" } } on success\n * // → { issues: [{ message: \"...\", path: [{ key: \"name\" }] }] } on failure\n *\n * // JSON Schema for OpenAI / LangChain tool calling\n * const parameters = schema[\"~standard\"].jsonSchema.input({ target: \"openai-strict\" });\n * // → { type: \"object\", properties: {...}, required: [...], additionalProperties: false }\n * ```\n *\n * @note Cross-field rules (sameAs, requiredIf, requiredWith) rely on sibling values\n * available in the full validation context. When called on a standalone scalar validator,\n * sibling data is absent and those rules will not evaluate correctly.\n * Always call on the parent ObjectValidator for full-payload validation.\n */\n get [\"~standard\"](): StandardJSONSchemaV1.Props<TInput, TOutput> {\n return {\n version: 1,\n vendor: \"seal\",\n types: undefined as unknown as StandardSchemaV1.Types<TInput, TOutput>,\n validate: async (value: unknown) => {\n const result = await validate(this, value);\n return mapToStandardResult(result) as StandardSchemaV1.Result<TOutput>;\n },\n jsonSchema: {\n input: (options) => this.toJsonSchema(options.target),\n output: (options) => this.toJsonSchema(options.target),\n },\n };\n }\n\n /**\n * Generate a JSON Schema representation of this validator.\n *\n * Supports targets: `\"draft-2020-12\"` (default), `\"draft-07\"`, `\"openapi-3.0\"`.\n *\n * Subclasses override this to describe their specific constraints.\n * The base implementation returns `{}` (permissive — accepts anything),\n * which is correct for validators with no representable JSON Schema constraints.\n *\n * @note Rules that cannot be expressed in JSON Schema are silently omitted:\n * - Cross-field rules: sameAs, requiredIf, requiredWith, requiredWithout\n * - Custom callbacks: refine()\n * - Framework-specific runtime rules (core/cascade plugins)\n * These rules still run normally at validation time — only absent from JSON Schema.\n *\n * @example\n * ```ts\n * v.string().min(3).max(50).toJsonSchema(\"draft-2020-12\")\n * // → { type: \"string\", minLength: 3, maxLength: 50 }\n *\n * v.object({ name: v.string().required(), age: v.int().optional() })\n * .toJsonSchema(\"draft-07\")\n * // → { type: \"object\", properties: { name: { type: \"string\" }, age: { type: \"integer\" } }, required: [\"name\"] }\n * ```\n */\n public toJsonSchema(_target: JsonSchemaTarget = \"draft-2020-12\"): Json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T;;;;CAKA,AAAU,sBAAsB,MAA4B;EAC1D,KAAK,QAAQ,iBACX,OAAO,KAAK,eAAe,KAAK,UAAU,WACrC,KAAK,eAAe,KAAK,QAC1B,KAAK;EACX,KAAK,QAAQ,uBAAuB,KAAK;CAC3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CA,KAAK,eAA4D;EAC/D,OAAO;GACL,SAAS;GACT,QAAQ;GACR,OAAO;GACP,UAAU,OAAO,UAAmB;IAElC,OAAO,oBAAoB,MADN,SAAS,MAAM,KAAK,CACR;GACnC;GACA,YAAY;IACV,QAAQ,YAAY,KAAK,aAAa,QAAQ,MAAM;IACpD,SAAS,YAAY,KAAK,aAAa,QAAQ,MAAM;GACvD;EACF;CACF;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BA,AAAO,aAAa,UAA4B,iBAAmC;EACjF,OAAO,CAAC;CACV;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"boolean-validator.mjs","names":[],"sources":["../../../../../../../../../seal/src/validators/boolean-validator.ts"],"sourcesContent":["import { booleanCoerceMutator, formBooleanMutator } from \"../mutators/boolean-mutators\";\nimport {\n acceptedIfPresentRule,\n acceptedIfRequiredRule,\n acceptedIfRule,\n acceptedRule,\n acceptedUnlessRule,\n acceptedWithoutRule,\n declinedIfPresentRule,\n declinedIfRequiredRule,\n declinedIfRule,\n declinedRule,\n declinedUnlessRule,\n declinedWithoutRule,\n} from \"../rules/scalar\";\nimport { booleanRule } from \"../rules\";\nimport { PrimitiveValidator } from \"./primitive-validator\";\nimport { applyNullable } from \"../standard-schema/json-schema\";\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\nimport type { SchemaRule, SchemaRuleOptions } from \"../types\";\n\n/**\n * Boolean validator class\n *\n * Extends PrimitiveValidator — inherits enum/in/oneOf/allowsOnly/forbids/notIn.\n * Defines accepted/declined directly as real methods (not ScalarValidator field copies)\n * so they survive cloning correctly.\n */\nexport class BooleanValidator extends PrimitiveValidator {\n public constructor(errorMessage?: string) {\n super();\n this.blankIsMissing = true;\n this.addMutableRule(booleanRule, errorMessage);\n }\n\n /**\n * Check if value is a boolean type\n */\n public matchesType(value: any): boolean {\n return typeof value === \"boolean\";\n }\n\n /**\n * Add a rule from the accepted/declined family, opting the validator into\n * form-boolean parsing.\n *\n * Calling ANY `accepted*`/`declined*` method on `v.boolean()` adds (once,\n * idempotently — checked by mutator identity so chaining several of these\n * methods never stacks duplicates) `formBooleanMutator`, which runs before\n * the type rule and converts the accepted set (`1`, `\"1\"`, `true`,\n * `\"true\"`, `\"yes\"`, `\"y\"`, `\"on\"`, `\"Yes\"`, `\"Y\"`, `\"On\"`) to `true` and\n * the declined set (`0`, `\"0\"`, `false`, `\"false\"`, `\"no\"`, `\"n\"`, `\"off\"`,\n * `\"No\"`, `\"N\"`, `\"Off\"`) to `false`; any other value passes through\n * unchanged and is rejected by the strict type rule as before.\n *\n * The mutator and the rule are added to the SAME resolved instance in one\n * pass — resolving `this.instance` twice (once per `addRule`/`addMutator`\n * call) would clone twice on an immutable validator and silently drop one\n * of the two additions.\n */\n private addFormBooleanRule<T extends SchemaRuleOptions = SchemaRuleOptions>(\n rule: SchemaRule<T>,\n errorMessage?: string,\n options: T = {} as T,\n ): this {\n const instance = this.instance;\n\n if (!instance.mutators.some((mutator) => mutator.mutate === formBooleanMutator)) {\n instance.addMutableMutator(formBooleanMutator);\n }\n\n instance.addMutableRule(rule, errorMessage, options);\n\n return instance;\n }\n\n // ==================== Accepted ====================\n\n /** Value must be accepted (true, \"yes\", 1, \"on\", etc. — form strings are parsed into a real boolean first) */\n public accepted(errorMessage?: string) {\n return this.addFormBooleanRule(acceptedRule, errorMessage);\n }\n\n /** Value must be accepted if another field equals a value */\n public acceptedIf(field: string, value: any, errorMessage?: string) {\n return this.addFormBooleanRule(acceptedIfRule, errorMessage, { field, value });\n }\n\n /** Value must be accepted unless another field equals a value */\n public acceptedUnless(field: string, value: any, errorMessage?: string) {\n return this.addFormBooleanRule(acceptedUnlessRule, errorMessage, { field, value });\n }\n\n /** Value must be accepted if another field is required */\n public acceptedIfRequired(field: string, errorMessage?: string) {\n return this.addFormBooleanRule(acceptedIfRequiredRule, errorMessage, { field });\n }\n\n /** Value must be accepted if another field is present */\n public acceptedIfPresent(field: string, errorMessage?: string) {\n return this.addFormBooleanRule(acceptedIfPresentRule, errorMessage, { field });\n }\n\n /** Value must be accepted if another field is missing */\n public acceptedWithout(field: string, errorMessage?: string) {\n return this.addFormBooleanRule(acceptedWithoutRule, errorMessage, { field });\n }\n\n // ==================== Declined ====================\n\n /** Value must be declined (false, \"no\", 0, \"off\", etc. — form strings are parsed into a real boolean first) */\n public declined(errorMessage?: string) {\n return this.addFormBooleanRule(declinedRule, errorMessage);\n }\n\n /** Value must be declined if another field equals a value */\n public declinedIf(field: string, value: any, errorMessage?: string) {\n return this.addFormBooleanRule(declinedIfRule, errorMessage, { field, value });\n }\n\n /** Value must be declined unless another field equals a value */\n public declinedUnless(field: string, value: any, errorMessage?: string) {\n return this.addFormBooleanRule(declinedUnlessRule, errorMessage, { field, value });\n }\n\n /** Value must be declined if another field is required */\n public declinedIfRequired(field: string, errorMessage?: string) {\n return this.addFormBooleanRule(declinedIfRequiredRule, errorMessage, { field });\n }\n\n /** Value must be declined if another field is present */\n public declinedIfPresent(field: string, errorMessage?: string) {\n return this.addFormBooleanRule(declinedIfPresentRule, errorMessage, { field });\n }\n\n /** Value must be declined if another field is missing */\n public declinedWithout(field: string, errorMessage?: string) {\n return this.addFormBooleanRule(declinedWithoutRule, errorMessage, { field });\n }\n\n // ==================== Coercion ====================\n\n /**\n * Opt in to coercion: an exact query-string-shaped boolean is converted to a\n * real boolean **before** the type rules run; any other value passes through\n * unchanged so bad input still fails the type rule.\n *\n * Converts exactly `\"true\"` / `\"1\"` / `1` → `true` and `\"false\"` / `\"0\"` / `0`\n * → `false`. Case-sensitive, no trimming — `\"TRUE\"`, `\"yes\"`, `\"on\"`, `\"\"`, and\n * `2` all pass through unchanged and fail the type rule. `v.boolean()` does\n * **not** coerce by default; this only takes effect when explicitly chained.\n * For form-style truthy strings like `\"yes\"` / `\"on\"`, use `.accepted()` /\n * `.declined()` instead — those methods opt into their own form-boolean\n * parsing (a wider value set, case-insensitive on a few forms) and then\n * apply the accepted/declined pass-fail rule on top of the parsed boolean.\n *\n * The output type is unchanged (`Infer<>` keys off the validator class), so\n * `v.boolean().coerce()` still infers `boolean`.\n *\n * @example\n * v.boolean().coerce() // \"true\" → true; \"1\" → true; \"0\" → false; \"yes\" → invalid\n */\n public coerce() {\n return this.addMutator(booleanCoerceMutator) as this & { isCoerced: true };\n }\n\n // ==================== Strict boolean checks ====================\n\n /**\n * Value must be strictly true (not \"yes\", \"on\", 1, etc.)\n * @alias accepted - strict version\n */\n public mustBeTrue(errorMessage?: string) {\n return this.equal(true, errorMessage);\n }\n\n /**\n * Value must be strictly false (not \"no\", \"off\", 0, etc.)\n * @alias declined - strict version\n */\n public mustBeFalse(errorMessage?: string) {\n return this.equal(false, errorMessage);\n }\n\n /**\n * @inheritdoc\n *\n * @note accepted/declined rules and all cross-field boolean rules\n * are not representable in JSON Schema and are silently omitted.\n *\n * @example\n * ```ts\n * v.boolean().toJsonSchema(\"draft-2020-12\")\n * // → { type: \"boolean\" }\n *\n * v.boolean().nullable().toJsonSchema(\"openapi-3.0\")\n * // → { type: \"boolean\", nullable: true }\n * ```\n */\n public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n const schema: JsonSchemaResult = { type: \"boolean\" };\n if (this.isNullable) applyNullable(schema, target);\n return schema;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,IAAa,mBAAb,cAAsC,mBAAmB;CACvD,AAAO,YAAY,cAAuB;EACxC,MAAM;EACN,KAAK,iBAAiB;EACtB,KAAK,eAAe,aAAa,YAAY;CAC/C;;;;CAKA,AAAO,YAAY,OAAqB;EACtC,OAAO,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E,MAAM,CAAC;CAChF;;CAGA,AAAO,kBAAkB,OAAe,cAAuB;EAC7D,OAAO,KAAK,mBAAmB,uBAAuB,cAAc,EAAE,MAAM,CAAC;CAC/E;;CAGA,AAAO,gBAAgB,OAAe,cAAuB;EAC3D,OAAO,KAAK,mBAAmB,qBAAqB,cAAc,EAAE,MAAM,CAAC;CAC7E;;;;;;;;;;;;;;;;;;;;;CAwBA,AAAO,SAAS;EACd,OAAO,KAAK,WAAW,oBAAoB;CAC7C;;;;;CAQA,AAAO,WAAW,cAAuB;EACvC,OAAO,KAAK,MAAM,MAAM,YAAY;CACtC;;;;;CAMA,AAAO,YAAY,cAAuB;EACxC,OAAO,KAAK,MAAM,OAAO,YAAY;CACvC;;;;;;;;;;;;;;;;CAiBA,AAAgB,aAAa,SAA2B,iBAAmC;EACzF,MAAM,SAA2B,EAAE,MAAM,UAAU;EACnD,IAAI,KAAK,YAAY,cAAc,QAAQ,MAAM;EACjD,OAAO;CACT;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"computed-validator.mjs","names":[],"sources":["../../../../../../../../../seal/src/validators/computed-validator.ts"],"sourcesContent":["import type { SchemaContext, ValidationResult } from \"../types\";\nimport { BaseValidator } from \"./base-validator\";\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\n\n/**\n * Callback function for computed fields\n * Receives validated & mutated data and full schema context\n */\nexport type ComputedCallback<TResult = any> = (\n data: any,\n context: SchemaContext,\n) => TResult | Promise<TResult>;\n\n/**\n * Computed field validator\n *\n * Computes a value based on other validated fields in the schema.\n * The computed value is persisted and can optionally be validated.\n *\n * @example\n * ```ts\n * // Basic computed field\n * const schema = v.object({\n * title: v.string().required(),\n * slug: v.computed(data => slugify(data.title)),\n * });\n *\n * // With result validation\n * const schema = v.object({\n * title: v.string().required(),\n * slug: v.computed(\n * data => slugify(data.title),\n * v.string().minLength(3)\n * ),\n * });\n *\n * // Async computation\n * const schema = v.object({\n * image: v.string().url(),\n * thumbnail: v.computed(async data => {\n * return await generateThumbnail(data.image);\n * }),\n * });\n * ```\n */\nexport class ComputedValidator<TResult = any> extends BaseValidator {\n /**\n * Create a new computed field validator\n *\n * @param callback - Function to compute the value from validated data\n * @param resultValidator - Optional validator to validate the computed result\n */\n public constructor(\n protected callback: ComputedCallback<TResult>,\n protected resultValidator?: BaseValidator,\n ) {\n super();\n }\n\n /**\n * Execute the callback and optionally validate the result\n */\n public async validate(data: any, context: SchemaContext): Promise<ValidationResult> {\n try {\n // Execute the callback with validated data\n const result = await this.callback(data, context);\n\n // Optionally validate the computed result\n if (this.resultValidator) {\n const validation = await this.resultValidator.validate(result, context);\n\n if (!validation.isValid) {\n return {\n isValid: false,\n errors: validation.errors,\n data: undefined,\n };\n }\n\n return {\n isValid: true,\n errors: [],\n data: validation.data,\n };\n }\n\n // No validation - return computed result directly\n return {\n isValid: true,\n errors: [],\n data: result,\n };\n } catch (error) {\n // Handle callback execution errors\n return {\n isValid: false,\n errors: [\n {\n type: \"computed\",\n error: error instanceof Error ? error.message : \"Computed field callback failed\",\n input: context.path,\n },\n ],\n data: undefined,\n };\n }\n }\n\n /**\n * Clone this validator with all its configuration\n * Critical for ObjectValidator.clone(), extend(), merge(), etc.\n */\n public override clone(): this {\n const cloned = super.clone();\n\n // Copy ComputedValidator-specific properties\n cloned.callback = this.callback; // Functions are safe to copy by reference\n cloned.resultValidator = this.resultValidator?.clone(); // Deep clone validator\n\n return cloned;\n }\n\n /**\n * Computed fields don't have a specific type to match\n */\n public matchesType(value: any): boolean {\n return true; // Computed fields accept any input (they generate their own value)\n }\n\n /**\n * @inheritdoc\n *\n * Computed fields are server-side runtime values — they have no input schema\n * and cannot be represented in JSON Schema. Calling this method is always a\n * programming error.\n *\n * @throws Error Always throws — computed/managed fields have no JSON Schema representation.\n */\n public override toJsonSchema(_target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n throw new Error(\n `[Seal] toJsonSchema() is not supported on ComputedValidator / ManagedValidator. ` +\n `Computed fields are runtime-only and have no input JSON Schema representation. ` +\n `ObjectValidator.toJsonSchema() automatically skips computed fields — ` +\n `do not call toJsonSchema() on a computed validator directly.`,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,IAAa,oBAAb,cAAsD,cAAc;CAQtD;CACA;;;;;;;CAFZ,AAAO,YACL,AAAU,UACV,AAAU,iBACV;EACA,MAAM;EAHI;EACA;CAGZ;;;;CAKA,MAAa,SAAS,MAAW,SAAmD;EAClF,IAAI;GAEF,MAAM,SAAS,MAAM,KAAK,SAAS,MAAM,OAAO;GAGhD,IAAI,KAAK,iBAAiB;IACxB,MAAM,aAAa,MAAM,KAAK,gBAAgB,SAAS,QAAQ,OAAO;IAEtE,IAAI,CAAC,WAAW,SACd,OAAO;KACL,SAAS;KACT,QAAQ,WAAW;KACnB,MAAM;IACR;IAGF,OAAO;KACL,SAAS;KACT,QAAQ,CAAC;KACT,MAAM,WAAW;IACnB;GACF;GAGA,OAAO;IACL,SAAS;IACT,QAAQ,CAAC;IACT,MAAM;GACR;EACF,SAAS,OAAO;GAEd,OAAO;IACL,SAAS;IACT,QAAQ,CACN;KACE,MAAM;KACN,OAAO,iBAAiB,QAAQ,MAAM,UAAU;KAChD,OAAO,QAAQ;IACjB,CACF;IACA,MAAM;GACR;EACF;CACF;;;;;CAMA,AAAgB,QAAc;EAC5B,MAAM,SAAS,MAAM,MAAM;EAG3B,OAAO,WAAW,KAAK;EACvB,OAAO,kBAAkB,KAAK,iBAAiB,MAAM;EAErD,OAAO;CACT;;;;CAKA,AAAO,YAAY,OAAqB;EACtC,OAAO;CACT;;;;;;;;;;CAWA,AAAgB,aAAa,UAA4B,iBAAmC;EAC1F,MAAM,IAAI,MACR,kSAIF;CACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"date-validator.mjs","names":[],"sources":["../../../../../../../../../seal/src/validators/date-validator.ts"],"sourcesContent":["import dayjs from \"dayjs\";\nimport {\n addDaysMutator,\n addHoursMutator,\n addMonthsMutator,\n addYearsMutator,\n dateMutator,\n toEndOfDayMutator,\n toEndOfMonthMutator,\n toEndOfYearMutator,\n toStartOfDayMutator,\n toStartOfMonthMutator,\n toStartOfYearMutator,\n toUTCMutator,\n} from \"../mutators\";\nimport {\n afterFieldRule,\n afterTodayRule,\n ageRule,\n beforeFieldRule,\n beforeHourRule,\n beforeMinuteRule,\n beforeTodayRule,\n betweenAgeRule,\n betweenDatesRule,\n betweenDaysRule,\n betweenHoursRule,\n betweenMinutesRule,\n betweenMonthsRule,\n betweenTimesRule,\n betweenYearsRule,\n birthdayRule,\n businessDayRule,\n dateRule,\n fromHourRule,\n fromMinuteRule,\n fromTodayRule,\n futureRule,\n leapYearRule,\n maxAgeRule,\n maxDateRule,\n maxDayRule,\n maxMonthRule,\n maxYearRule,\n minAgeRule,\n minDateRule,\n minDayRule,\n minMonthRule,\n minYearRule,\n type Month,\n monthRule,\n pastRule,\n quarterRule,\n sameAsFieldDateRule,\n todayRule,\n weekDayRule,\n weekdaysRule,\n weekendRule,\n withinDaysRule,\n withinFutureDaysRule,\n withinPastDaysRule,\n yearRule,\n} from \"../rules\";\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\nimport { applyNullable, getRuleOptions } from \"../standard-schema/json-schema\";\nimport type { WeekDay } from \"../types/date-types\";\nimport { isDateValue } from \"./../helpers/date-helpers\";\nimport { BaseValidator } from \"./base-validator\";\n\n/**\n * Date validator class\n */\nexport class DateValidator extends BaseValidator {\n public constructor(errorMessage?: string) {\n super();\n this.blankIsMissing = true;\n this.addMutableMutator(dateMutator); // Normalize to Date object first\n this.addMutableRule(dateRule, errorMessage);\n }\n\n /**\n * Check if value is a Date type\n */\n public matchesType(value: any): boolean {\n return isDateValue(value);\n }\n\n // ==================== Output Transformers ====================\n // These transform the Date after validation into different formats\n\n /**\n * Convert date to ISO string format\n * @category transformer\n */\n public toISOString() {\n return this.addTransformer((data) => (data instanceof Date ? data.toISOString() : data));\n }\n\n /** Convert date to Unix timestamp (milliseconds) */\n public toTimestamp() {\n return this.addTransformer((data) => (data instanceof Date ? data.getTime() : data));\n }\n\n // ==================== String Format Transformers ====================\n // These convert Date to formatted strings after validation\n\n /** Convert date to specific format using dayjs */\n public toFormat(format: string) {\n return this.addTransformer(\n (data, { options }) => (data instanceof Date ? dayjs(data).format(options.format) : data),\n { format },\n );\n }\n\n /** Convert to date only (remove time, returns YYYY-MM-DD) */\n public toDateOnly() {\n return this.addTransformer(\n (data) => (data instanceof Date ? dayjs(data).format(\"YYYY-MM-DD\") : data),\n { __jsonSchemaFormat: \"date\" },\n );\n }\n\n /** Convert to time only (returns HH:MM:SS) */\n public toTimeOnly() {\n return this.addTransformer(\n (data) => (data instanceof Date ? dayjs(data).format(\"HH:mm:ss\") : data),\n { __jsonSchemaFormat: \"time\" },\n );\n }\n\n // ==================== Date Mutators ====================\n // These modify the Date object before validation\n\n /**\n * Convert date to start of day (00:00:00)\n * @category mutator\n */\n public toStartOfDay() {\n return this.addMutator(toStartOfDayMutator);\n }\n\n /** Convert date to end of day (23:59:59.999) */\n public toEndOfDay() {\n return this.addMutator(toEndOfDayMutator);\n }\n\n /** Add or subtract days from date */\n public addDays(days: number) {\n return this.addMutator(addDaysMutator, { days });\n }\n\n /** Add or subtract months from date */\n public addMonths(months: number) {\n return this.addMutator(addMonthsMutator, { months });\n }\n\n /** Add or subtract years from date */\n public addYears(years: number) {\n return this.addMutator(addYearsMutator, { years });\n }\n\n /** Add or subtract hours from date */\n public addHours(hours: number) {\n return this.addMutator(addHoursMutator, { hours });\n }\n\n /** Convert date to UTC */\n public toUTC() {\n return this.addMutator(toUTCMutator);\n }\n\n // ==================== Date Range Mutators ====================\n\n /** Set to start of month */\n public toStartOfMonth() {\n return this.addMutator(toStartOfMonthMutator);\n }\n\n /** Set to end of month */\n public toEndOfMonth() {\n return this.addMutator(toEndOfMonthMutator);\n }\n\n /** Set to start of year */\n public toStartOfYear() {\n return this.addMutator(toStartOfYearMutator);\n }\n\n /** Set to end of year */\n public toEndOfYear() {\n return this.addMutator(toEndOfYearMutator);\n }\n\n // ==================== Date Comparison ====================\n\n /**\n * Date must be greater than or equal to the given date or field (inclusive)\n *\n * Smart detection:\n * - Date instance, timestamp, or date string (with - or /) → value comparison\n * - Plain string → field comparison\n *\n * @param dateOrField - Date, timestamp, date string, or field name\n *\n * @example\n * ```ts\n * // Value comparison\n * v.date().min('2024-01-01')\n * v.date().min(new Date())\n * v.date().min(1698278400000)\n *\n * // Field comparison\n * v.date().min('startsAt')\n * ```\n *\n * @category Validation Rule\n */\n public min(dateOrField: Date | string | number, errorMessage?: string): this {\n return this.addRule(minDateRule, errorMessage, {\n dateOrField,\n scope: \"global\",\n });\n }\n\n /**\n * Date must be less than or equal to the given date or field (inclusive)\n *\n * Smart detection:\n * - Date instance, timestamp, or date string (with - or /) → value comparison\n * - Plain string → field comparison\n *\n * @category Validation Rule\n */\n public max(dateOrField: Date | string | number, errorMessage?: string): this {\n return this.addRule(maxDateRule, errorMessage, {\n dateOrField,\n scope: \"global\",\n });\n }\n\n /**\n * Date must be strictly less than the given date or field (exclusive)\n *\n * Smart detection:\n * - Date instance, timestamp, or date string (with - or /) → value comparison\n * - Plain string → field comparison\n *\n * @category Validation Rule\n */\n public before(dateOrField: Date | string | number, errorMessage?: string): this {\n return this.addRule(beforeFieldRule, errorMessage, {\n dateOrField,\n scope: \"global\",\n });\n }\n\n /**\n * Date must be strictly greater than the given date or field (exclusive)\n *\n * Smart detection:\n * - Date instance, timestamp, or date string (with - or /) → value comparison\n * - Plain string → field comparison\n *\n * @category Validation Rule\n */\n public after(dateOrField: Date | string | number, errorMessage?: string): this {\n return this.addRule(afterFieldRule, errorMessage, {\n dateOrField,\n scope: \"global\",\n });\n }\n\n /** Date must be between start and end dates */\n public between(startDate: Date, endDate: Date, errorMessage?: string) {\n return this.addRule(betweenDatesRule, errorMessage, { startDate, endDate });\n }\n\n /** Date must be exactly today */\n public today(errorMessage?: string) {\n return this.addRule(todayRule, errorMessage);\n }\n\n /** Date must be today or in the future */\n public fromToday(errorMessage?: string) {\n return this.addRule(fromTodayRule, errorMessage);\n }\n\n /** Date must be before today */\n public beforeToday(errorMessage?: string) {\n return this.addRule(beforeTodayRule, errorMessage);\n }\n\n /** Date must be after today (not including today) */\n public afterToday(errorMessage?: string) {\n return this.addRule(afterTodayRule, errorMessage);\n }\n\n /** Date must be in the past */\n public past(errorMessage?: string) {\n return this.addRule(pastRule, errorMessage);\n }\n\n /** Date must be in the future */\n public future(errorMessage?: string) {\n return this.addRule(futureRule, errorMessage);\n }\n\n // ==================== Sibling Field Comparison ====================\n // Explicit sibling scope methods\n\n /**\n * Date must be >= sibling field value (inclusive)\n * @category Validation Rule\n */\n public minSibling(field: string, errorMessage?: string): this {\n return this.addRule(minDateRule, errorMessage, {\n dateOrField: field,\n scope: \"sibling\",\n });\n }\n\n /**\n * Date must be <= sibling field value (inclusive)\n * @category Validation Rule\n */\n public maxSibling(field: string, errorMessage?: string): this {\n return this.addRule(maxDateRule, errorMessage, {\n dateOrField: field,\n scope: \"sibling\",\n });\n }\n\n /**\n * Date must be < sibling field value (exclusive)\n * @category Validation Rule\n */\n public beforeSibling(field: string, errorMessage?: string): this {\n return this.addRule(beforeFieldRule, errorMessage, {\n dateOrField: field,\n scope: \"sibling\",\n });\n }\n\n /**\n * Date must be > sibling field value (exclusive)\n * @category Validation Rule\n */\n public afterSibling(field: string, errorMessage?: string): this {\n return this.addRule(afterFieldRule, errorMessage, {\n dateOrField: field,\n scope: \"sibling\",\n });\n }\n\n /** Date must be the same as another field's date */\n public sameAsField(field: string, errorMessage?: string) {\n return this.addRule(sameAsFieldDateRule, errorMessage, {\n field,\n scope: \"global\",\n });\n }\n\n /** Date must be the same as another sibling field's date */\n public sameAsFieldSibling(field: string, errorMessage?: string) {\n return this.addRule(sameAsFieldDateRule, errorMessage, {\n field,\n scope: \"sibling\",\n });\n }\n\n // ==================== Time Validation ====================\n\n /** Time must be from specific hour onwards (0-23) */\n public fromHour(hour: number, errorMessage?: string) {\n return this.addRule(fromHourRule, errorMessage, { hour });\n }\n\n /** Time must be before specific hour (0-23) */\n public beforeHour(hour: number, errorMessage?: string) {\n return this.addRule(beforeHourRule, errorMessage, { hour });\n }\n\n /** Time must be between start and end hours (0-23) */\n public betweenHours(startHour: number, endHour: number, errorMessage?: string) {\n return this.addRule(betweenHoursRule, errorMessage, { startHour, endHour });\n }\n\n /** Time must be from specific minute onwards (0-59) */\n public fromMinute(minute: number, errorMessage?: string) {\n return this.addRule(fromMinuteRule, errorMessage, { minute });\n }\n\n /** Time must be before specific minute (0-59) */\n public beforeMinute(minute: number, errorMessage?: string) {\n return this.addRule(beforeMinuteRule, errorMessage, { minute });\n }\n\n /** Time must be between start and end minutes (0-59) */\n public betweenMinutes(startMinute: number, endMinute: number, errorMessage?: string) {\n return this.addRule(betweenMinutesRule, errorMessage, {\n startMinute,\n endMinute,\n });\n }\n\n /** Time must be between start and end times (HH:MM format) */\n public betweenTimes(startTime: string, endTime: string, errorMessage?: string) {\n return this.addRule(betweenTimesRule, errorMessage, { startTime, endTime });\n }\n\n // ==================== Age Validation ====================\n\n /** Age must be exactly the given years */\n public age(years: number, errorMessage?: string) {\n return this.addRule(ageRule, errorMessage, { years });\n }\n\n /** Minimum age requirement */\n public minAge(years: number, errorMessage?: string) {\n return this.addRule(minAgeRule, errorMessage, { years });\n }\n\n /** Maximum age requirement */\n public maxAge(years: number, errorMessage?: string) {\n return this.addRule(maxAgeRule, errorMessage, { years });\n }\n\n /** Age must be between min and max years */\n public betweenAge(minAge: number, maxAge: number, errorMessage?: string) {\n return this.addRule(betweenAgeRule, errorMessage, { minAge, maxAge });\n }\n\n // ==================== Day Validation ====================\n\n /** Date must be specific weekday */\n public weekDay(day: WeekDay, errorMessage?: string) {\n return this.addRule(weekDayRule, errorMessage, { day });\n }\n\n /** Date must be one of specified weekdays */\n public weekdays(days: WeekDay[], errorMessage?: string) {\n return this.addRule(weekdaysRule, errorMessage, { days });\n }\n\n /** Date must be a weekend (Saturday or Sunday) */\n public weekend(errorMessage?: string) {\n return this.addRule(weekendRule, errorMessage);\n }\n\n /** Date must be a business day (Monday-Friday) */\n public businessDay(errorMessage?: string) {\n return this.addRule(businessDayRule, errorMessage);\n }\n\n /** Date must match specific format */\n public format(format: string, errorMessage?: string) {\n return this.addRule(dateRule, errorMessage, { format });\n }\n\n // ==================== Relative Date Validation ====================\n\n /** Date must be within X days from now (past or future) */\n public withinDays(days: number, errorMessage?: string) {\n return this.addRule(withinDaysRule, errorMessage, { days });\n }\n\n /** Date must be within X days in the past */\n public withinPastDays(days: number, errorMessage?: string) {\n return this.addRule(withinPastDaysRule, errorMessage, { days });\n }\n\n /** Date must be within X days in the future */\n public withinFutureDays(days: number, errorMessage?: string) {\n return this.addRule(withinFutureDaysRule, errorMessage, { days });\n }\n\n // ==================== Period Validation ====================\n\n /** Date must be in specific month (1-12) */\n public month(month: Month, errorMessage?: string) {\n return this.addRule(monthRule, errorMessage, { month });\n }\n\n /** Date must be in specific year */\n public year(year: number, errorMessage?: string) {\n return this.addRule(yearRule, errorMessage, { year });\n }\n\n /**\n * Date must be between start and end years\n * Smart detection: number or field name\n *\n * @category Validation Rule\n */\n public betweenYears(startYear: number | string, endYear: number | string, errorMessage?: string) {\n return this.addRule(betweenYearsRule, errorMessage, {\n startYear,\n endYear,\n scope: \"global\",\n });\n }\n\n /**\n * Date must be between start and end months (1-12)\n * Smart detection: number or field name\n *\n * @category Validation Rule\n */\n public betweenMonths(\n startMonth: Month | string,\n endMonth: Month | string,\n errorMessage?: string,\n ) {\n return this.addRule(betweenMonthsRule, errorMessage, {\n startMonth,\n endMonth,\n scope: \"global\",\n });\n }\n\n /**\n * Date must be between start and end days (1-31)\n * Smart detection: number or field name\n *\n * @category Validation Rule\n */\n public betweenDays(startDay: number | string, endDay: number | string, errorMessage?: string) {\n return this.addRule(betweenDaysRule, errorMessage, {\n startDay,\n endDay,\n scope: \"global\",\n });\n }\n\n /**\n * Date must be between sibling field years\n * @category Validation Rule\n */\n public betweenYearsSibling(startYearField: string, endYearField: string, errorMessage?: string) {\n return this.addRule(betweenYearsRule, errorMessage, {\n startYear: startYearField,\n endYear: endYearField,\n scope: \"sibling\",\n });\n }\n\n /**\n * Date must be between sibling field months\n * @category Validation Rule\n */\n public betweenMonthsSibling(\n startMonthField: string,\n endMonthField: string,\n errorMessage?: string,\n ) {\n return this.addRule(betweenMonthsRule, errorMessage, {\n startMonth: startMonthField,\n endMonth: endMonthField,\n scope: \"sibling\",\n });\n }\n\n /**\n * Date must be between sibling field days\n * @category Validation Rule\n */\n public betweenDaysSibling(startDayField: string, endDayField: string, errorMessage?: string) {\n return this.addRule(betweenDaysRule, errorMessage, {\n startDay: startDayField,\n endDay: endDayField,\n scope: \"sibling\",\n });\n }\n\n /**\n * Year must be >= given year or field\n * Smart detection: number or field name\n *\n * @example\n * ```ts\n * // Value comparison\n * v.date().minYear(2024)\n *\n * // Field comparison\n * v.date().minYear('startYear')\n * ```\n *\n * @category Validation Rule\n */\n public minYear(yearOrField: number | string, errorMessage?: string): this {\n return this.addRule(minYearRule, errorMessage, {\n yearOrField,\n scope: \"global\",\n });\n }\n\n /**\n * Year must be <= given year or field\n * Smart detection: number or field name\n *\n * @category Validation Rule\n */\n public maxYear(yearOrField: number | string, errorMessage?: string): this {\n return this.addRule(maxYearRule, errorMessage, {\n yearOrField,\n scope: \"global\",\n });\n }\n\n /**\n * Month must be >= given month or field (1-12)\n * Smart detection: number or field name\n *\n * @category Validation Rule\n */\n public minMonth(monthOrField: number | string, errorMessage?: string): this {\n return this.addRule(minMonthRule, errorMessage, {\n monthOrField,\n scope: \"global\",\n });\n }\n\n /**\n * Month must be <= given month or field (1-12)\n * Smart detection: number or field name\n *\n * @category Validation Rule\n */\n public maxMonth(monthOrField: Month | string, errorMessage?: string): this {\n return this.addRule(maxMonthRule, errorMessage, {\n monthOrField,\n scope: \"global\",\n });\n }\n\n /**\n * Day must be >= given day or field (1-31)\n * Smart detection: number or field name\n *\n * @category Validation Rule\n */\n public minDay(dayOrField: number | string, errorMessage?: string): this {\n return this.addRule(minDayRule, errorMessage, {\n dayOrField,\n scope: \"global\",\n });\n }\n\n /**\n * Day must be <= given day or field (1-31)\n * Smart detection: number or field name\n *\n * @category Validation Rule\n */\n public maxDay(dayOrField: number | string, errorMessage?: string): this {\n return this.addRule(maxDayRule, errorMessage, {\n dayOrField,\n scope: \"global\",\n });\n }\n\n /**\n * Year must be >= sibling field year\n * @category Validation Rule\n */\n public minYearSibling(field: string, errorMessage?: string): this {\n return this.addRule(minYearRule, errorMessage, {\n yearOrField: field,\n scope: \"sibling\",\n });\n }\n\n /**\n * Year must be <= sibling field year\n * @category Validation Rule\n */\n public maxYearSibling(field: string, errorMessage?: string): this {\n return this.addRule(maxYearRule, errorMessage, {\n yearOrField: field,\n scope: \"sibling\",\n });\n }\n\n /**\n * Month must be >= sibling field month\n * @category Validation Rule\n */\n public minMonthSibling(field: string, errorMessage?: string): this {\n return this.addRule(minMonthRule, errorMessage, {\n monthOrField: field,\n scope: \"sibling\",\n });\n }\n\n /**\n * Month must be <= sibling field month\n * @category Validation Rule\n */\n public maxMonthSibling(field: string, errorMessage?: string): this {\n return this.addRule(maxMonthRule, errorMessage, {\n monthOrField: field,\n scope: \"sibling\",\n });\n }\n\n /**\n * Day must be >= sibling field day\n * @category Validation Rule\n */\n public minDaySibling(field: string, errorMessage?: string): this {\n return this.addRule(minDayRule, errorMessage, {\n dayOrField: field,\n scope: \"sibling\",\n });\n }\n\n /**\n * Day must be <= sibling field day\n * @category Validation Rule\n */\n public maxDaySibling(field: string, errorMessage?: string): this {\n return this.addRule(maxDayRule, errorMessage, {\n dayOrField: field,\n scope: \"sibling\",\n });\n }\n\n /** Date must be in specific quarter (1-4) */\n public quarter(quarter: 1 | 2 | 3 | 4, errorMessage?: string) {\n return this.addRule(quarterRule, errorMessage, { quarter });\n }\n\n // ==================== Special Validation ====================\n\n /** Valid birthday (not in future, reasonable age) */\n public birthday(minAge?: number, maxAge?: number, errorMessage?: string) {\n return this.addRule(birthdayRule, errorMessage, { minAge, maxAge });\n }\n\n /** Date must be in a leap year */\n public leapYear(errorMessage?: string) {\n return this.addRule(leapYearRule, errorMessage);\n }\n\n /**\n * Set default value as current time of exeuction\n */\n public defaultNow() {\n return this.default(() => new Date());\n }\n\n /**\n * @inheritdoc\n *\n * Maps DateValidator to JSON Schema format keywords.\n * Default is `date-time`. If `.toDateOnly()` or `.toTimeOnly()` are used,\n * falls back to `date` or `time` formats respectively.\n *\n * @example\n * ```ts\n * v.date().toJsonSchema(\"draft-2020-12\")\n * // → { type: \"string\", format: \"date-time\" }\n *\n * v.date().toDateOnly().toJsonSchema(\"draft-2020-12\")\n * // → { type: \"string\", format: \"date\" }\n * ```\n */\n public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n const schema: JsonSchemaResult = { type: \"string\", format: \"date-time\" };\n\n // Check if an explicit format rule was applied via v.date().format()\n const dateOpts = getRuleOptions(this.rules, \"date\");\n if (dateOpts?.format === \"YYYY-MM-DD\") {\n schema.format = \"date\";\n } else if (dateOpts?.format === \"HH:mm:ss\") {\n schema.format = \"time\";\n }\n\n // Transformer-based detection (marker-driven; minifier-safe).\n // toDateOnly/toTimeOnly tag their options bag with __jsonSchemaFormat.\n // toFormat() exposes the user-supplied format string in options.format.\n if (schema.format === \"date-time\") {\n for (const t of this.dataTransformers) {\n const hint = t.options?.__jsonSchemaFormat;\n if (hint === \"date\" || hint === \"time\") {\n schema.format = hint;\n break;\n }\n\n const userFormat = t.options?.format;\n\n if (userFormat === \"YYYY-MM-DD\") {\n schema.format = \"date\";\n break;\n }\n\n if (userFormat === \"HH:mm:ss\") {\n schema.format = \"time\";\n break;\n }\n }\n }\n\n if (this.isNullable) applyNullable(schema, target);\n\n return schema;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwEA,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QAAQ,YAAY,cAAc;GAC5C,YAAY;GACZ,OAAO;EACT,CAAC;CACH;;CAGA,AAAO,QAAQ,SAAwB,cAAuB;EAC5D,OAAO,KAAK,QAAQ,aAAa,cAAc,EAAE,QAAQ,CAAC;CAC5D;;CAKA,AAAO,SAAS,QAAiB,QAAiB,cAAuB;EACvE,OAAO,KAAK,QAAQ,cAAc,cAAc;GAAE;GAAQ;EAAO,CAAC;CACpE;;CAGA,AAAO,SAAS,cAAuB;EACrC,OAAO,KAAK,QAAQ,cAAc,YAAY;CAChD;;;;CAKA,AAAO,aAAa;EAClB,OAAO,KAAK,8BAAc,IAAI,KAAK,CAAC;CACtC;;;;;;;;;;;;;;;;;CAkBA,AAAgB,aAAa,SAA2B,iBAAmC;EACzF,MAAM,SAA2B;GAAE,MAAM;GAAU,QAAQ;EAAY;EAGvE,MAAM,WAAW,eAAe,KAAK,OAAO,MAAM;EAClD,IAAI,UAAU,WAAW,cACvB,OAAO,SAAS;OACX,IAAI,UAAU,WAAW,YAC9B,OAAO,SAAS;EAMlB,IAAI,OAAO,WAAW,aACpB,KAAK,MAAM,KAAK,KAAK,kBAAkB;GACrC,MAAM,OAAO,EAAE,SAAS;GACxB,IAAI,SAAS,UAAU,SAAS,QAAQ;IACtC,OAAO,SAAS;IAChB;GACF;GAEA,MAAM,aAAa,EAAE,SAAS;GAE9B,IAAI,eAAe,cAAc;IAC/B,OAAO,SAAS;IAChB;GACF;GAEA,IAAI,eAAe,YAAY;IAC7B,OAAO,SAAS;IAChB;GACF;EACF;EAGF,IAAI,KAAK,YAAY,cAAc,QAAQ,MAAM;EAEjD,OAAO;CACT;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"discriminated-union-validator.mjs","names":[],"sources":["../../../../../../../../../seal/src/validators/discriminated-union-validator.ts"],"sourcesContent":["import { isPlainObject } from \"@mongez/supportive-is\";\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\nimport { applyNullable, wrapNullableStrict } from \"../standard-schema/json-schema\";\nimport type { SchemaContext, ValidationResult } from \"../types\";\nimport { BaseValidator } from \"./base-validator\";\nimport { LiteralValidator } from \"./literal-validator\";\nimport { ObjectValidator } from \"./object-validator\";\n\n/** A literal value a discriminator field can hold (the key type of the branch map). */\ntype DiscriminatorValue = string | number | boolean;\n\n/** Whether a value read from the payload can be a discriminator key. */\nfunction isDiscriminatorValue(value: unknown): value is DiscriminatorValue {\n return typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\";\n}\n\n/**\n * Discriminated union validator — routes payloads by a shared discriminator field.\n *\n * Plain `v.union()` falls back to `matchesType()` to pick a branch, which is\n * coarse for object-vs-object unions (every branch matches \"is plain object\").\n * Discriminated union reads a known field's value and routes directly to the\n * matching branch, producing precise errors instead of confused mash from the\n * wrong branch.\n *\n * **Construction-time validation.** Every branch must:\n * - Be an `ObjectValidator`\n * - Declare the discriminator field\n * - Type the discriminator as `v.literal(...)` (single or multi-literal both work)\n * - Not collide with another branch's literal values\n *\n * Misconfigurations throw eagerly so tests catch them at schema-build time.\n *\n * @example\n * ```ts\n * const email = v.object({ type: v.literal(\"email\"), email: v.string().email() });\n * const sms = v.object({ type: v.literal(\"sms\"), phone: v.string() });\n * const push = v.object({ type: v.literal(\"push\"), deviceId: v.string() });\n *\n * const notif = v.discriminatedUnion(\"type\", [email, sms, push]);\n *\n * await validate(notif, { type: \"sms\", phone: \"555-1234\" });\n * // → routes to sms branch only; errors (if any) come from sms\n * ```\n *\n * @see `domains/seal/plans/2026-05-12-discriminated-union.md`\n */\nexport class DiscriminatedUnionValidator<\n K extends string = string,\n Branches extends ReadonlyArray<ObjectValidator<any>> = ReadonlyArray<ObjectValidator<any>>,\n> extends BaseValidator {\n /** Map from discriminator literal value → matching branch validator. */\n private branches: Map<DiscriminatorValue, ObjectValidator<any>>;\n\n public constructor(\n public discriminator: K,\n public validators: Branches,\n ) {\n super();\n\n this.branches = DiscriminatedUnionValidator.buildBranchMap(discriminator, validators);\n }\n\n /**\n * Walk every branch, pull out the discriminator's literal values, and build\n * the lookup map. Throws on misconfiguration (missing discriminator,\n * non-literal discriminator, duplicate literal value).\n */\n private static buildBranchMap(\n discriminator: string,\n validators: ReadonlyArray<ObjectValidator<any>>,\n ): Map<DiscriminatorValue, ObjectValidator<any>> {\n const map = new Map<DiscriminatorValue, ObjectValidator<any>>();\n\n for (const branch of validators) {\n const discriminatorValidator = branch.schema?.[discriminator];\n\n if (!discriminatorValidator) {\n throw new Error(\n `[Seal] discriminatedUnion: branch missing discriminator field \"${discriminator}\"`,\n );\n }\n\n if (!(discriminatorValidator instanceof LiteralValidator)) {\n throw new Error(\n `[Seal] discriminatedUnion: discriminator \"${discriminator}\" must be v.literal(...) on every branch`,\n );\n }\n\n for (const value of discriminatorValidator.values) {\n if (map.has(value)) {\n throw new Error(\n `[Seal] discriminatedUnion: duplicate discriminator value \"${String(value)}\"`,\n );\n }\n map.set(value, branch);\n }\n }\n\n return map;\n }\n\n public override matchesType(value: any): boolean {\n return isPlainObject(value);\n }\n\n public override async validate(data: any, context: SchemaContext): Promise<ValidationResult> {\n if (data === null && this.isNullable) {\n return { isValid: true, errors: [], data: null };\n }\n\n if (!isPlainObject(data)) {\n return {\n isValid: false,\n errors: [\n {\n type: \"discriminatedUnion\",\n error: `Expected object with discriminator field \"${this.discriminator}\"`,\n input: context.key || context.path || \"value\",\n },\n ],\n data: undefined,\n };\n }\n\n const discriminatorValue = data[this.discriminator];\n const branch = isDiscriminatorValue(discriminatorValue)\n ? this.branches.get(discriminatorValue)\n : undefined;\n\n if (!branch) {\n const allowed = [...this.branches.keys()].map((k) => String(k)).join(\", \");\n return {\n isValid: false,\n errors: [\n {\n type: \"discriminatedUnion\",\n error: `Field \"${this.discriminator}\" must be one of: ${allowed}`,\n input: this.discriminator,\n },\n ],\n data: undefined,\n };\n }\n\n return branch.validate(data, context);\n }\n\n public override clone(): this {\n const cloned = super.clone() as any;\n cloned.discriminator = this.discriminator;\n cloned.validators = this.validators.map((v: ObjectValidator<any>) => v.clone());\n cloned.branches = DiscriminatedUnionValidator.buildBranchMap(\n cloned.discriminator,\n cloned.validators,\n );\n return cloned;\n }\n\n /**\n * Emit `oneOf` of branch schemas. Each branch's own `toJsonSchema()` handles\n * its `properties.{discriminator}.const` and the surrounding required/optional\n * structure — we just enumerate.\n *\n * For `openai-strict`: the per-branch ObjectValidator already inflates\n * `required` to include every field; `oneOf` is OpenAI-accepted as long as\n * each branch passes strict rules independently.\n */\n public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n const oneOf = this.validators.map((v) => v.toJsonSchema(target));\n const schema: JsonSchemaResult = { oneOf };\n\n if (this.isNullable) {\n if (target === \"openai-strict\") {\n return wrapNullableStrict(schema);\n }\n applyNullable(schema, target);\n }\n\n return schema;\n }\n}\n"],"mappings":";;;;;;;AAYA,SAAS,qBAAqB,OAA6C;CACzE,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU;AACpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAa,8BAAb,MAAa,oCAGH,cAAc;CAKb;CACA;;CAJT,AAAQ;CAER,AAAO,YACL,AAAO,eACP,AAAO,YACP;EACA,MAAM;EAHC;EACA;EAIP,KAAK,WAAW,4BAA4B,eAAe,eAAe,UAAU;CACtF;;;;;;CAOA,OAAe,eACb,eACA,YAC+C;EAC/C,MAAM,sBAAM,IAAI,IAA8C;EAE9D,KAAK,MAAM,UAAU,YAAY;GAC/B,MAAM,yBAAyB,OAAO,SAAS;GAE/C,IAAI,CAAC,wBACH,MAAM,IAAI,MACR,kEAAkE,cAAc,EAClF;GAGF,IAAI,EAAE,kCAAkC,mBACtC,MAAM,IAAI,MACR,6CAA6C,cAAc,yCAC7D;GAGF,KAAK,MAAM,SAAS,uBAAuB,QAAQ;IACjD,IAAI,IAAI,IAAI,KAAK,GACf,MAAM,IAAI,MACR,6DAA6D,OAAO,KAAK,EAAE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ACnB,IAAI,WAAW,iBACb,OAAO,mBAAmB,MAAM;GAElC,cAAc,QAAQ,MAAM;EAC9B;EAEA,OAAO;CACT;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"float-validator.mjs","names":[],"sources":["../../../../../../../../../seal/src/validators/float-validator.ts"],"sourcesContent":["import { floatRule } from \"../rules\";\nimport { NumberValidator } from \"./number-validator\";\n\n/**\n * Float validator class\n */\nexport class FloatValidator extends NumberValidator {\n public constructor(errorMessage?: string) {\n super();\n this.addMutableRule(floatRule, errorMessage);\n }\n}\n"],"mappings":";;;;;;;;AAMA,IAAa,iBAAb,cAAoC,gBAAgB;CAClD,AAAO,YAAY,cAAuB;EACxC,MAAM;EACN,KAAK,eAAe,WAAW,YAAY;CAC7C;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instanceof-validator.mjs","names":[],"sources":["../../../../../../../../../seal/src/validators/instanceof-validator.ts"],"sourcesContent":["import { instanceofRule } from \"../rules/common/instanceof\";\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\nimport { BaseValidator } from \"./base-validator\";\n\n/**\n * InstanceOf validator class\n *\n * Validates that the value is an instance of the given constructor (`value instanceof Ctor`).\n * Useful for File uploads, Buffer/Uint8Array payloads, and custom domain classes —\n * anywhere a runtime class identity is the right contract.\n *\n * Note: `Date` is already covered by `v.date()` with richer date-specific rules;\n * reach for `v.instanceof(Date)` only when you specifically want raw `instanceof`\n * semantics with no normalization.\n *\n * @example\n * v.instanceof(File) // type: File\n * v.instanceof(Buffer) // type: Buffer\n * v.instanceof(MyClass) // type: MyClass\n */\nexport class InstanceOfValidator<T = unknown> extends BaseValidator {\n public ctor: new (...args: any[]) => T;\n\n public constructor(ctor: new (...args: any[]) => T, errorMessage?: string) {\n super();\n this.ctor = ctor;\n this.addMutableRule(instanceofRule, errorMessage, { ctor, name: ctor.name || \"instance\" });\n }\n\n /**\n * Check if value is an instance of the configured constructor\n */\n public matchesType(value: any): boolean {\n return value instanceof this.ctor;\n }\n\n /**\n * Clone the validator, preserving the target constructor.\n *\n * The base `clone()` only copies `BaseValidator` fields, so without this\n * override a cloned `instanceof` validator loses its `ctor` reference and\n * `matchesType()` would throw on the next call.\n */\n public override clone(): this {\n const cloned = super.clone();\n cloned.ctor = this.ctor;\n return cloned;\n }\n\n /**\n * @inheritdoc\n *\n * Class instances are not representable in JSON Schema — returns an empty\n * schema (permissive). Consumers serializing to OpenAPI should attach an\n * appropriate format manually if needed (e.g. `{ type: \"string\", format: \"binary\" }`\n * for `File`).\n */\n public override toJsonSchema(_target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n return {};\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,IAAa,sBAAb,cAAsD,cAAc;CAClE,AAAO;CAEP,AAAO,YAAY,MAAiC,cAAuB;EACzE,MAAM;EACN,KAAK,OAAO;EACZ,KAAK,eAAe,gBAAgB,cAAc;GAAE;GAAM,MAAM,KAAK,QAAQ;EAAW,CAAC;CAC3F;;;;CAKA,AAAO,YAAY,OAAqB;EACtC,OAAO,iBAAiB,KAAK;CAC/B;;;;;;;;CASA,AAAgB,QAAc;EAC5B,MAAM,SAAS,MAAM,MAAM;EAC3B,OAAO,OAAO,KAAK;EACnB,OAAO;CACT;;;;;;;;;CAUA,AAAgB,aAAa,UAA4B,iBAAmC;EAC1F,OAAO,CAAC;CACV;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"int-validator.mjs","names":[],"sources":["../../../../../../../../../seal/src/validators/int-validator.ts"],"sourcesContent":["import { intRule } from \"../rules\";\nimport { NumberValidator } from \"./number-validator\";\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\n\n/**\n * Integer validator class\n */\nexport class IntValidator extends NumberValidator {\n public constructor(errorMessage?: string) {\n super();\n this.addMutableRule(intRule, errorMessage);\n }\n\n /**\n * @inheritdoc — returns `{ type: \"integer\" }` instead of `{ type: \"number\" }`\n *\n * @example\n * ```ts\n * v.int().min(1).max(100).toJsonSchema(\"draft-2020-12\")\n * // → { type: \"integer\", minimum: 1, maximum: 100 }\n * ```\n */\n public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n return this.buildNumberJsonSchema(\"integer\", target);\n }\n}\n"],"mappings":";;;;;;;;AAOA,IAAa,eAAb,cAAkC,gBAAgB;CAChD,AAAO,YAAY,cAAuB;EACxC,MAAM;EACN,KAAK,eAAe,SAAS,YAAY;CAC3C;;;;;;;;;;CAWA,AAAgB,aAAa,SAA2B,iBAAmC;EACzF,OAAO,KAAK,sBAAsB,WAAW,MAAM;CACrD;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lazy-validator.mjs","names":[],"sources":["../../../../../../../../../seal/src/validators/lazy-validator.ts"],"sourcesContent":["import type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\nimport type { SchemaContext, ValidationResult } from \"../types\";\nimport { BaseValidator } from \"./base-validator\";\n\n/**\n * Lazy validator — defers resolution of the inner validator until validate-time.\n *\n * Solves the chicken-and-egg of self-referencing schemas. JavaScript evaluates\n * an object literal before the `const` binding completes, so this can't work:\n *\n * ```ts\n * const categorySchema = v.object({\n * name: v.string(),\n * children: v.array(categorySchema), // ❌ ReferenceError\n * });\n * ```\n *\n * Wrap the recursive reference in `v.lazy(() => …)` — the thunk isn't invoked\n * during construction, only when `validate()` is called:\n *\n * ```ts\n * type Category = { name: string; children: Category[] };\n *\n * const categorySchema: ObjectValidator<...> = v.object({\n * name: v.string(),\n * children: v.array(v.lazy(() => categorySchema)),\n * });\n *\n * type T = Infer<typeof categorySchema>;\n * // { name: string; children: T[] } ← recursive type\n * ```\n *\n * The thunk is memoized — it's invoked once on the first validate (or\n * `matchesType` / `toJsonSchema`) call and the result is cached. The thunk is\n * expected to return a stable validator; calling it on every validate would be\n * wasteful and could mask bugs where the user accidentally returns a fresh\n * validator each time.\n *\n * **JSON Schema caveat.** v1 uses simple resolve-and-delegate — recursive\n * schemas will infinite-loop in `toJsonSchema()`. If you need JSON Schema for\n * a recursive shape, generate it manually with `$defs` + `$ref` until v2 lands.\n *\n * @see `domains/seal/plans/2026-05-12-lazy-validator.md`\n */\nexport class LazyValidator<T extends BaseValidator = BaseValidator> extends BaseValidator {\n private resolvedValidator: T | undefined;\n\n public constructor(private thunk: () => T) {\n super();\n // Lazy itself defers required handling to the inner validator —\n // mark the wrapper as optional so the required check doesn't fire here.\n this.requiredRule = null;\n this.isOptional = true;\n }\n\n /**\n * Resolve the inner validator. Memoizes the result so subsequent calls\n * don't re-execute the thunk.\n */\n private resolve(): T {\n if (this.resolvedValidator === undefined) {\n this.resolvedValidator = this.thunk();\n }\n\n return this.resolvedValidator;\n }\n\n public override async validate(data: any, context: SchemaContext): Promise<ValidationResult> {\n return this.resolve().validate(data, context);\n }\n\n public override matchesType(value: any): boolean {\n return this.resolve().matchesType(value);\n }\n\n public override clone(): this {\n const cloned = super.clone();\n // Share the thunk reference; reset the memo so the clone resolves\n // independently on its first call (in case the thunk closure resolves\n // differently in a different context — unlikely but cheap insurance).\n cloned.thunk = this.thunk;\n cloned.resolvedValidator = undefined;\n\n return cloned;\n }\n\n /**\n * JSON Schema generation — simple resolve-and-delegate.\n *\n * **Recursive schemas will infinite-loop.** Until v2 adds `$ref` + `$defs`\n * generation, callers needing JSON Schema for recursive shapes must build\n * the schema manually.\n */\n public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n return this.resolve().toJsonSchema(target);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,IAAa,gBAAb,cAA4E,cAAc;CAG7D;CAF3B,AAAQ;CAER,AAAO,YAAY,AAAQ,OAAgB;EACzC,MAAM;EADmB;EAIzB,KAAK,eAAe;EACpB,KAAK,aAAa;CACpB;;;;;CAMA,AAAQ,UAAa;EACnB,IAAI,KAAK,sBAAsB,QAC7B,KAAK,oBAAoB,KAAK,MAAM;EAGtC,OAAO,KAAK;CACd;CAEA,MAAsB,SAAS,MAAW,SAAmD;EAC3F,OAAO,KAAK,QAAQ,CAAC,CAAC,SAAS,MAAM,OAAO;CAC9C;CAEA,AAAgB,YAAY,OAAqB;EAC/C,OAAO,KAAK,QAAQ,CAAC,CAAC,YAAY,KAAK;CACzC;CAEA,AAAgB,QAAc;EAC5B,MAAM,SAAS,MAAM,MAAM;EAI3B,OAAO,QAAQ,KAAK;EACpB,OAAO,oBAAoB;EAE3B,OAAO;CACT;;;;;;;;CASA,AAAgB,aAAa,SAA2B,iBAAmC;EACzF,OAAO,KAAK,QAAQ,CAAC,CAAC,aAAa,MAAM;CAC3C;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"literal-validator.mjs","names":[],"sources":["../../../../../../../../../seal/src/validators/literal-validator.ts"],"sourcesContent":["import { literalRule } from \"../rules/common/literal\";\nimport { applyNullable } from \"../standard-schema/json-schema\";\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\nimport { BaseValidator } from \"./base-validator\";\n\n/**\n * Literal validator class\n *\n * Accepts a fixed tuple of primitive literal values (string, number, boolean).\n * The TypeScript type narrows to the union of those literals — `v.literal(\"a\", \"b\")`\n * infers as `\"a\" | \"b\"`, not `string`. Use for discriminator fields, enum-like\n * unions of constants, and any case where `oneOf([...])` would lose literal types.\n *\n * @example\n * v.literal(\"items\") // type: \"items\"\n * v.literal(\"draft\", \"published\") // type: \"draft\" | \"published\"\n * v.literal(1, 2, 3) // type: 1 | 2 | 3\n * v.literal(true) // type: true\n */\nexport class LiteralValidator<\n T extends readonly (string | number | boolean)[] = readonly (string | number | boolean)[],\n> extends BaseValidator {\n public values: T;\n\n public constructor(values: T, errorMessage?: string) {\n super();\n this.blankIsMissing = true;\n this.values = values;\n this.addMutableRule(literalRule, errorMessage, { values });\n\n // `\"\"` is a value, not an absence. Every validator is required by default,\n // and `required` rejects anything `isEmptyValue` calls empty — including the\n // empty string — so `v.literal(\"\")` could never pass. When the author has\n // explicitly listed an empty value as acceptable, swap `required` for\n // `present`: the key must still exist, but judging the value is the literal\n // set's job, and it is already the stricter statement of intent.\n //\n // Dropping the rule entirely instead would make a missing key valid, which\n // is the opposite mistake — `alt=\"\"` and no `alt` at all are different\n // things to a screen reader, and to anything else reading the schema.\n }\n\n /**\n * Check if value is one of the configured literals\n */\n public matchesType(value: any): boolean {\n return (this.values as readonly any[]).includes(value);\n }\n\n /**\n * Clone the validator, preserving the literal `values` set.\n *\n * The base `clone()` only copies `BaseValidator` fields, so without this\n * override a cloned literal loses its public `values` array — which breaks\n * any consumer that reads it (e.g. `discriminatedUnion` branch routing).\n */\n public override clone(): this {\n const cloned = super.clone();\n cloned.values = this.values;\n return cloned;\n }\n\n /**\n * @inheritdoc\n *\n * Single literal → `{ const: <value> }`. Multiple → `{ enum: [...] }`.\n *\n * @example\n * ```ts\n * v.literal(\"items\").toJsonSchema()\n * // → { const: \"items\" }\n *\n * v.literal(\"draft\", \"published\").toJsonSchema()\n * // → { enum: [\"draft\", \"published\"] }\n * ```\n */\n public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n const schema: JsonSchemaResult =\n this.values.length === 1 ? { const: this.values[0] } : { enum: [...this.values] };\n if (this.isNullable) applyNullable(schema, target);\n return schema;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,IAAa,mBAAb,cAEU,cAAc;CACtB,AAAO;CAEP,AAAO,YAAY,QAAW,cAAuB;EACnD,MAAM;EACN,KAAK,iBAAiB;EACtB,KAAK,SAAS;EACd,KAAK,eAAe,aAAa,cAAc,EAAE,OAAO,CAAC;CAY3D;;;;CAKA,AAAO,YAAY,OAAqB;EACtC,OAAQ,KAAK,OAA0B,SAAS,KAAK;CACvD;;;;;;;;CASA,AAAgB,QAAc;EAC5B,MAAM,SAAS,MAAM,MAAM;EAC3B,OAAO,SAAS,KAAK;EACrB,OAAO;CACT;;;;;;;;;;;;;;;CAgBA,AAAgB,aAAa,SAA2B,iBAAmC;EACzF,MAAM,SACJ,KAAK,OAAO,WAAW,IAAI,EAAE,OAAO,KAAK,OAAO,GAAG,IAAI,EAAE,MAAM,CAAC,GAAG,KAAK,MAAM,EAAE;EAClF,IAAI,KAAK,YAAY,cAAc,QAAQ,MAAM;EACjD,OAAO;CACT;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"managed-validator.mjs","names":[],"sources":["../../../../../../../../../seal/src/validators/managed-validator.ts"],"sourcesContent":["import type { SchemaContext } from \"../types\";\nimport type { BaseValidator } from \"./base-validator\";\nimport { ComputedValidator, type ComputedCallback } from \"./computed-validator\";\n\n/**\n * Callback function for managed fields\n * Receives only schema context (no data dependency)\n */\nexport type ManagedCallback<TResult = any> = (context: SchemaContext) => TResult | Promise<TResult>;\n\n/**\n * Managed field validator\n *\n * The callback is optional - if not provided, the framework can inject the value.\n * @example\n * ```ts\n * // With callback (framework executes it)\n * const schema = v.object({\n * name: v.string(),\n * createdAt: v.managed(() => new Date()),\n * updatedAt: v.managed(() => new Date()),\n * });\n *\n * // Without callback (framework injects value)\n * const schema = v.object({\n * name: v.string(),\n * id: v.managed(() => 1),\n * });\n * ```\n */\nexport class ManagedValidator<TResult = any> extends ComputedValidator<TResult> {\n /**\n * Create a new managed field validator\n *\n * @param callback - Optional function to generate the value\n * @param resultValidator - Optional validator to validate the generated result\n */\n constructor(callback: ManagedCallback<TResult>, resultValidator?: BaseValidator) {\n // Convert ManagedCallback to ComputedCallback\n // Managed callbacks don't receive data, only context\n const computedCallback: ComputedCallback<TResult> = (_data, context) => callback(context);\n\n super(computedCallback, resultValidator);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAa,mBAAb,cAAqD,kBAA2B;;;;;;;CAO9E,YAAY,UAAoC,iBAAiC;EAG/E,MAAM,oBAA+C,OAAO,YAAY,SAAS,OAAO;EAExF,MAAM,kBAAkB,eAAe;CACzC;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"equality-conditional-methods.mjs","names":[],"sources":["../../../../../../../../../../seal/src/validators/methods/equality-conditional-methods.ts"],"sourcesContent":["import { equalsFieldRule, notEqualsFieldRule } from \"../../rules\";\nimport { equalRule } from \"../../rules/core/equal\";\nimport { whenRule } from \"../../rules/core/when\";\nimport type { WhenRuleOptions } from \"../../types\";\nimport { BaseValidator } from \"../base-validator\";\n\n/**\n * Marker re-exported by the validators barrel so the dts bundler keeps this\n * module (and its `declare module` augmentation) in the bundled `.d.ts`.\n */\nexport const equalityConditionalMethodsApplied = true;\n\ndeclare module \"../base-validator\" {\n interface BaseValidator {\n /**\n * Value must be equal to the given value\n */\n equal(value: any, errorMessage?: string): this;\n\n /**\n * Value must be the same as another field's value\n */\n sameAs(field: string, errorMessage?: string): this;\n\n /**\n * Value must be the same as another sibling field's value\n */\n sameAsSibling(field: string, errorMessage?: string): this;\n\n /**\n * Value must be different from another field's value\n */\n differentFrom(field: string, errorMessage?: string): this;\n\n /**\n * Value must be different from another sibling field's value\n */\n differentFromSibling(field: string, errorMessage?: string): this;\n\n /**\n * Apply different validation rules based on another field's value (global scope)\n *\n * Use this when you need to apply completely different validators\n * based on another field's value (not just required/optional).\n *\n * @param field - Field name to check (can be nested with dot notation)\n * @param options - Validation options per field value\n *\n * @example\n * ```ts\n * // Different allowed values based on user type\n * v.object({\n * userType: v.string().in(['admin', 'user']),\n * role: v.string().when('userType', {\n * is: {\n * admin: v.string().in(['super', 'moderator']),\n * user: v.string().in(['member', 'guest'])\n * },\n * otherwise: v.string().optional()\n * })\n * })\n *\n * // Different validation rules based on type\n * v.object({\n * contactType: v.string().in(['email', 'phone']),\n * contact: v.string().when('contactType', {\n * is: {\n * email: v.string().email(),\n * phone: v.string().pattern(/^\\d{10}$/)\n * }\n * })\n * })\n * ```\n * @category Conditional Validation\n */\n when(field: string, options: Omit<WhenRuleOptions, \"field\" | \"scope\">): this;\n\n /**\n * Apply different validation rules based on sibling field's value\n *\n * Use this for nested objects where you need to check a field\n * within the same parent object.\n *\n * @param siblingField - Sibling field name to check\n * @param options - Validation options per field value\n *\n * @example\n * ```ts\n * // Array of users with role-based permissions\n * v.array(v.object({\n * userType: v.string().in(['admin', 'user']),\n * permissions: v.string().whenSibling('userType', {\n * is: {\n * admin: v.string().in(['read', 'write', 'delete']),\n * user: v.string().in(['read'])\n * }\n * })\n * }))\n * ```\n * @category Conditional Validation\n */\n whenSibling(siblingField: string, options: Omit<WhenRuleOptions, \"field\" | \"scope\">): this;\n }\n}\n\n/**\n * Value must be equal to the given value\n */\nBaseValidator.prototype.equal = function (value: any, errorMessage?: string) {\n return this.addRule(equalRule, errorMessage, { value });\n};\n\n/**\n * Value must be the same as another field's value\n */\nBaseValidator.prototype.sameAs = function (field: string, errorMessage?: string) {\n return this.addRule(equalsFieldRule, errorMessage, {\n field,\n scope: \"global\",\n });\n};\n\n/**\n * Value must be the same as another sibling field's value\n */\nBaseValidator.prototype.sameAsSibling = function (field: string, errorMessage?: string) {\n return this.addRule(equalsFieldRule, errorMessage, {\n field,\n scope: \"sibling\",\n });\n};\n\n/**\n * Value must be different from another field's value\n */\nBaseValidator.prototype.differentFrom = function (field: string, errorMessage?: string) {\n return this.addRule(notEqualsFieldRule, errorMessage, {\n field,\n scope: \"global\",\n });\n};\n\n/**\n * Value must be different from another sibling field's value\n */\nBaseValidator.prototype.differentFromSibling = function (field: string, errorMessage?: string) {\n return this.addRule(notEqualsFieldRule, errorMessage, {\n field,\n scope: \"sibling\",\n });\n};\n\n/**\n * Apply different validation rules based on another field's value (global scope)\n *\n * Use this when you need to apply completely different validators\n * based on another field's value (not just required/optional).\n *\n * @param field - Field name to check (can be nested with dot notation)\n * @param options - Validation options per field value\n *\n * @example\n * ```ts\n * // Different allowed values based on user type\n * v.object({\n * userType: v.string().in(['admin', 'user']),\n * role: v.string().when('userType', {\n * is: {\n * admin: v.string().in(['super', 'moderator']),\n * user: v.string().in(['member', 'guest'])\n * },\n * otherwise: v.string().optional()\n * })\n * })\n *\n * // Different validation rules based on type\n * v.object({\n * contactType: v.string().in(['email', 'phone']),\n * contact: v.string().when('contactType', {\n * is: {\n * email: v.string().email(),\n * phone: v.string().pattern(/^\\d{10}$/)\n * }\n * })\n * })\n * ```\n * @category Conditional Validation\n */\nBaseValidator.prototype.when = function (\n field: string,\n options: Omit<WhenRuleOptions, \"field\" | \"scope\">,\n) {\n return this.addRule(whenRule, undefined, {\n field,\n is: options.is,\n otherwise: options.otherwise,\n scope: \"global\",\n });\n};\n\n/**\n * Apply different validation rules based on sibling field's value\n *\n * Use this for nested objects where you need to check a field\n * within the same parent object.\n *\n * @param siblingField - Sibling field name to check\n * @param options - Validation options per field value\n *\n * @example\n * ```ts\n * // Array of users with role-based permissions\n * v.array(v.object({\n * userType: v.string().in(['admin', 'user']),\n * permissions: v.string().whenSibling('userType', {\n * is: {\n * admin: v.string().in(['read', 'write', 'delete']),\n * user: v.string().in(['read'])\n * }\n * })\n * }))\n * ```\n * @category Conditional Validation\n */\nBaseValidator.prototype.whenSibling = function (\n siblingField: string,\n options: Omit<WhenRuleOptions, \"field\" | \"scope\">,\n) {\n return this.addRule(whenRule, undefined, {\n field: siblingField,\n is: options.is,\n otherwise: options.otherwise,\n scope: \"sibling\",\n });\n};\n"],"mappings":";;;;;;;;;;AA4GA,cAAc,UAAU,QAAQ,SAAU,OAAY,cAAuB;CAC3E,OAAO,KAAK,QAAQ,WAAW,cAAc,EAAE,MAAM,CAAC;AACxD;;;;AAKA,cAAc,UAAU,SAAS,SAAU,OAAe,cAAuB;CAC/E,OAAO,KAAK,QAAQ,iBAAiB,cAAc;EACjD;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,gBAAgB,SAAU,OAAe,cAAuB;CACtF,OAAO,KAAK,QAAQ,iBAAiB,cAAc;EACjD;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,gBAAgB,SAAU,OAAe,cAAuB;CACtF,OAAO,KAAK,QAAQ,oBAAoB,cAAc;EACpD;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,uBAAuB,SAAU,OAAe,cAAuB;CAC7F,OAAO,KAAK,QAAQ,oBAAoB,cAAc;EACpD;EACA,OAAO;CACT,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,cAAc,UAAU,OAAO,SAC7B,OACA,SACA;CACA,OAAO,KAAK,QAAQ,UAAU,QAAW;EACvC;EACA,IAAI,QAAQ;EACZ,WAAW,QAAQ;EACnB,OAAO;CACT,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,cAAc,UAAU,cAAc,SACpC,cACA,SACA;CACA,OAAO,KAAK,QAAQ,UAAU,QAAW;EACvC,OAAO;EACP,IAAI,QAAQ;EACZ,WAAW,QAAQ;EACnB,OAAO;CACT,CAAC;AACH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"forbidden-methods.mjs","names":[],"sources":["../../../../../../../../../../seal/src/validators/methods/forbidden-methods.ts"],"sourcesContent":["import {\n forbiddenIfEmptyRule,\n forbiddenIfInRule,\n forbiddenIfNotEmptyRule,\n forbiddenIfNotInRule,\n forbiddenIfNotRule,\n forbiddenIfRule,\n} from \"../../rules/conditional/forbidden-if-rules\";\nimport { forbiddenRule } from \"../../rules/core/forbidden\";\nimport { BaseValidator } from \"../base-validator\";\n\n/**\n * Marker re-exported by the validators barrel so the dts bundler keeps this\n * module (and its `declare module` augmentation) in the bundled `.d.ts`.\n */\nexport const forbiddenMethodsApplied = true;\n\ndeclare module \"../base-validator\" {\n interface BaseValidator {\n /**\n * Value is forbidden to be present\n */\n forbidden(errorMessage?: string): this;\n\n /**\n * Value is forbidden if another field equals a specific value (global scope)\n */\n forbiddenIf(field: string, value: any, errorMessage?: string): this;\n\n /**\n * Value is forbidden if another field equals a specific value (sibling scope)\n */\n forbiddenIfSibling(field: string, value: any, errorMessage?: string): this;\n\n /**\n * Value is forbidden if another field does NOT equal a specific value (global scope)\n */\n forbiddenIfNot(field: string, value: any, errorMessage?: string): this;\n\n /**\n * Value is forbidden if another field does NOT equal a specific value (sibling scope)\n */\n forbiddenIfNotSibling(field: string, value: any, errorMessage?: string): this;\n\n /**\n * Value is forbidden if another field is empty (global scope)\n */\n forbiddenIfEmpty(field: string, errorMessage?: string): this;\n\n /**\n * Value is forbidden if another field is empty (sibling scope)\n */\n forbiddenIfEmptySibling(field: string, errorMessage?: string): this;\n\n /**\n * Value is forbidden if another field is not empty (global scope)\n */\n forbiddenIfNotEmpty(field: string, errorMessage?: string): this;\n\n /**\n * Value is forbidden if another field is not empty (sibling scope)\n */\n forbiddenIfNotEmptySibling(field: string, errorMessage?: string): this;\n\n /**\n * Value is forbidden if another field's value is in the given array (global scope)\n */\n forbiddenIfIn(field: string, values: any[], errorMessage?: string): this;\n\n /**\n * Value is forbidden if another field's value is in the given array (sibling scope)\n */\n forbiddenIfInSibling(field: string, values: any[], errorMessage?: string): this;\n\n /**\n * Value is forbidden if another field's value is NOT in the given array (global scope)\n */\n forbiddenIfNotIn(field: string, values: any[], errorMessage?: string): this;\n\n /**\n * Value is forbidden if another field's value is NOT in the given array (sibling scope)\n */\n forbiddenIfNotInSibling(field: string, values: any[], errorMessage?: string): this;\n }\n}\n\n/**\n * Value is forbidden to be present\n */\nBaseValidator.prototype.forbidden = function (errorMessage?: string) {\n return this.addRule(forbiddenRule, errorMessage);\n};\n\n/**\n * Value is forbidden if another field equals a specific value (global scope)\n */\nBaseValidator.prototype.forbiddenIf = function (field: string, value: any, errorMessage?: string) {\n return this.addRule(forbiddenIfRule, errorMessage, {\n field,\n value,\n scope: \"global\",\n });\n};\n\n/**\n * Value is forbidden if another field equals a specific value (sibling scope)\n */\nBaseValidator.prototype.forbiddenIfSibling = function (\n field: string,\n value: any,\n errorMessage?: string,\n) {\n return this.addRule(forbiddenIfRule, errorMessage, {\n field,\n value,\n scope: \"sibling\",\n });\n};\n\n/**\n * Value is forbidden if another field does NOT equal a specific value (global scope)\n */\nBaseValidator.prototype.forbiddenIfNot = function (\n field: string,\n value: any,\n errorMessage?: string,\n) {\n return this.addRule(forbiddenIfNotRule, errorMessage, {\n field,\n value,\n scope: \"global\",\n });\n};\n\n/**\n * Value is forbidden if another field does NOT equal a specific value (sibling scope)\n */\nBaseValidator.prototype.forbiddenIfNotSibling = function (\n field: string,\n value: any,\n errorMessage?: string,\n) {\n return this.addRule(forbiddenIfNotRule, errorMessage, {\n field,\n value,\n scope: \"sibling\",\n });\n};\n\n/**\n * Value is forbidden if another field is empty (global scope)\n */\nBaseValidator.prototype.forbiddenIfEmpty = function (field: string, errorMessage?: string) {\n return this.addRule(forbiddenIfEmptyRule, errorMessage, {\n field,\n scope: \"global\",\n });\n};\n\n/**\n * Value is forbidden if another field is empty (sibling scope)\n */\nBaseValidator.prototype.forbiddenIfEmptySibling = function (field: string, errorMessage?: string) {\n return this.addRule(forbiddenIfEmptyRule, errorMessage, {\n field,\n scope: \"sibling\",\n });\n};\n\n/**\n * Value is forbidden if another field is not empty (global scope)\n */\nBaseValidator.prototype.forbiddenIfNotEmpty = function (field: string, errorMessage?: string) {\n return this.addRule(forbiddenIfNotEmptyRule, errorMessage, {\n field,\n scope: \"global\",\n });\n};\n\n/**\n * Value is forbidden if another field is not empty (sibling scope)\n */\nBaseValidator.prototype.forbiddenIfNotEmptySibling = function (\n field: string,\n errorMessage?: string,\n) {\n return this.addRule(forbiddenIfNotEmptyRule, errorMessage, {\n field,\n scope: \"sibling\",\n });\n};\n\n/**\n * Value is forbidden if another field's value is in the given array (global scope)\n */\nBaseValidator.prototype.forbiddenIfIn = function (\n field: string,\n values: any[],\n errorMessage?: string,\n) {\n return this.addRule(forbiddenIfInRule, errorMessage, {\n field,\n values,\n scope: \"global\",\n });\n};\n\n/**\n * Value is forbidden if another field's value is in the given array (sibling scope)\n */\nBaseValidator.prototype.forbiddenIfInSibling = function (\n field: string,\n values: any[],\n errorMessage?: string,\n) {\n return this.addRule(forbiddenIfInRule, errorMessage, {\n field,\n values,\n scope: \"sibling\",\n });\n};\n\n/**\n * Value is forbidden if another field's value is NOT in the given array (global scope)\n */\nBaseValidator.prototype.forbiddenIfNotIn = function (\n field: string,\n values: any[],\n errorMessage?: string,\n) {\n return this.addRule(forbiddenIfNotInRule, errorMessage, {\n field,\n values,\n scope: \"global\",\n });\n};\n\n/**\n * Value is forbidden if another field's value is NOT in the given array (sibling scope)\n */\nBaseValidator.prototype.forbiddenIfNotInSibling = function (\n field: string,\n values: any[],\n errorMessage?: string,\n) {\n return this.addRule(forbiddenIfNotInRule, errorMessage, {\n field,\n values,\n scope: \"sibling\",\n });\n};\n"],"mappings":";;;;;;;;AAyFA,cAAc,UAAU,YAAY,SAAU,cAAuB;CACnE,OAAO,KAAK,QAAQ,eAAe,YAAY;AACjD;;;;AAKA,cAAc,UAAU,cAAc,SAAU,OAAe,OAAY,cAAuB;CAChG,OAAO,KAAK,QAAQ,iBAAiB,cAAc;EACjD;EACA;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,qBAAqB,SAC3C,OACA,OACA,cACA;CACA,OAAO,KAAK,QAAQ,iBAAiB,cAAc;EACjD;EACA;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,iBAAiB,SACvC,OACA,OACA,cACA;CACA,OAAO,KAAK,QAAQ,oBAAoB,cAAc;EACpD;EACA;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,wBAAwB,SAC9C,OACA,OACA,cACA;CACA,OAAO,KAAK,QAAQ,oBAAoB,cAAc;EACpD;EACA;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,mBAAmB,SAAU,OAAe,cAAuB;CACzF,OAAO,KAAK,QAAQ,sBAAsB,cAAc;EACtD;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,0BAA0B,SAAU,OAAe,cAAuB;CAChG,OAAO,KAAK,QAAQ,sBAAsB,cAAc;EACtD;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,sBAAsB,SAAU,OAAe,cAAuB;CAC5F,OAAO,KAAK,QAAQ,yBAAyB,cAAc;EACzD;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,6BAA6B,SACnD,OACA,cACA;CACA,OAAO,KAAK,QAAQ,yBAAyB,cAAc;EACzD;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,gBAAgB,SACtC,OACA,QACA,cACA;CACA,OAAO,KAAK,QAAQ,mBAAmB,cAAc;EACnD;EACA;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,uBAAuB,SAC7C,OACA,QACA,cACA;CACA,OAAO,KAAK,QAAQ,mBAAmB,cAAc;EACnD;EACA;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,mBAAmB,SACzC,OACA,QACA,cACA;CACA,OAAO,KAAK,QAAQ,sBAAsB,cAAc;EACtD;EACA;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,0BAA0B,SAChD,OACA,QACA,cACA;CACA,OAAO,KAAK,QAAQ,sBAAsB,cAAc;EACtD;EACA;EACA,OAAO;CACT,CAAC;AACH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"present-methods.mjs","names":[],"sources":["../../../../../../../../../../seal/src/validators/methods/present-methods.ts"],"sourcesContent":["import {\n presentIfEmptyRule,\n presentIfInRule,\n presentIfNotEmptyRule,\n presentIfNotInRule,\n presentIfRule,\n} from \"../../rules/conditional/present-if-rules\";\nimport { presentUnlessRule } from \"../../rules/conditional/present-unless-rules\";\nimport {\n presentWithAllRule,\n presentWithAnyRule,\n presentWithRule,\n} from \"../../rules/conditional/present-with-rules\";\nimport {\n presentWithoutAllRule,\n presentWithoutAnyRule,\n presentWithoutRule,\n} from \"../../rules/conditional/present-without-rules\";\nimport { BaseValidator } from \"../base-validator\";\n\n/**\n * Marker re-exported by the validators barrel so the dts bundler keeps this\n * module (and its `declare module` augmentation) in the bundled `.d.ts`.\n */\nexport const presentMethodsApplied = true;\n\ndeclare module \"../base-validator\" {\n interface BaseValidator {\n /**\n * Field must be present if another field exists\n */\n presentWith(field: string, errorMessage?: string): this;\n\n /**\n * Field must be present if another sibling field exists\n */\n presentWithSibling(field: string, errorMessage?: string): this;\n\n /**\n * Field must be present if another field is missing\n */\n presentWithout(field: string, errorMessage?: string): this;\n\n /**\n * Field must be present if another sibling field is missing\n */\n presentWithoutSibling(field: string, errorMessage?: string): this;\n\n /**\n * Field must be present if another field equals a specific value\n */\n presentIf(field: string, value: any, errorMessage?: string): this;\n\n /**\n * Field must be present if another sibling field equals a specific value\n */\n presentIfSibling(field: string, value: any, errorMessage?: string): this;\n\n /**\n * Field must be present unless another field equals a specific value\n */\n presentUnless(field: string, value: any, errorMessage?: string): this;\n\n /**\n * Field must be present unless another sibling field equals a specific value\n */\n presentUnlessSibling(field: string, value: any, errorMessage?: string): this;\n\n /**\n * Field must be present if another field is empty\n */\n presentIfEmpty(field: string, errorMessage?: string): this;\n\n /**\n * Field must be present if another sibling field is empty\n */\n presentIfEmptySibling(field: string, errorMessage?: string): this;\n\n /**\n * Field must be present if another field is not empty\n */\n presentIfNotEmpty(field: string, errorMessage?: string): this;\n\n /**\n * Field must be present if another sibling field is not empty\n */\n presentIfNotEmptySibling(field: string, errorMessage?: string): this;\n\n /**\n * Field must be present if another field's value is in the given array\n */\n presentIfIn(field: string, values: any[], errorMessage?: string): this;\n\n /**\n * Field must be present if another sibling field's value is in the given array\n */\n presentIfInSibling(field: string, values: any[], errorMessage?: string): this;\n\n /**\n * Field must be present if another field's value is NOT in the given array\n */\n presentIfNotIn(field: string, values: any[], errorMessage?: string): this;\n\n /**\n * Field must be present if another sibling field's value is NOT in the given array\n */\n presentIfNotInSibling(field: string, values: any[], errorMessage?: string): this;\n\n /**\n * Field must be present if all specified fields exist\n */\n presentWithAll(fields: string[], errorMessage?: string): this;\n\n /**\n * Field must be present if all specified sibling fields exist\n */\n presentWithAllSiblings(fields: string[], errorMessage?: string): this;\n\n /**\n * Field must be present if all specified fields are missing\n */\n presentWithoutAll(fields: string[], errorMessage?: string): this;\n\n /**\n * Field must be present if all specified sibling fields are missing\n */\n presentWithoutAllSiblings(fields: string[], errorMessage?: string): this;\n\n /**\n * Field must be present if any of the specified fields exists\n */\n presentWithAny(fields: string[], errorMessage?: string): this;\n\n /**\n * Field must be present if any of the specified sibling fields exists\n */\n presentWithAnySiblings(fields: string[], errorMessage?: string): this;\n\n /**\n * Field must be present if any of the specified fields is missing\n */\n presentWithoutAny(fields: string[], errorMessage?: string): this;\n\n /**\n * Field must be present if any of the specified sibling fields is missing\n */\n presentWithoutAnySiblings(fields: string[], errorMessage?: string): this;\n }\n}\n\n// ==================== PRESENT: BASED ON FIELD PRESENCE ====================\n\n/**\n * Field must be present if another field exists\n */\nBaseValidator.prototype.presentWith = function (field: string, errorMessage?: string) {\n return this.addRule(presentWithRule, errorMessage, {\n field,\n scope: \"global\",\n });\n};\n\n/**\n * Field must be present if another sibling field exists\n */\nBaseValidator.prototype.presentWithSibling = function (field: string, errorMessage?: string) {\n return this.addRule(presentWithRule, errorMessage, {\n field,\n scope: \"sibling\",\n });\n};\n\n/**\n * Field must be present if another field is missing\n */\nBaseValidator.prototype.presentWithout = function (field: string, errorMessage?: string) {\n return this.addRule(presentWithoutRule, errorMessage, {\n field,\n scope: \"global\",\n });\n};\n\n/**\n * Field must be present if another sibling field is missing\n */\nBaseValidator.prototype.presentWithoutSibling = function (field: string, errorMessage?: string) {\n return this.addRule(presentWithoutRule, errorMessage, {\n field,\n scope: \"sibling\",\n });\n};\n\n// ==================== PRESENT: BASED ON FIELD VALUE ====================\n\n/**\n * Field must be present if another field equals a specific value\n */\nBaseValidator.prototype.presentIf = function (field: string, value: any, errorMessage?: string) {\n return this.addRule(presentIfRule, errorMessage, {\n field,\n value,\n scope: \"global\",\n });\n};\n\n/**\n * Field must be present if another sibling field equals a specific value\n */\nBaseValidator.prototype.presentIfSibling = function (\n field: string,\n value: any,\n errorMessage?: string,\n) {\n return this.addRule(presentIfRule, errorMessage, {\n field,\n value,\n scope: \"sibling\",\n });\n};\n\n/**\n * Field must be present unless another field equals a specific value\n */\nBaseValidator.prototype.presentUnless = function (\n field: string,\n value: any,\n errorMessage?: string,\n) {\n return this.addRule(presentUnlessRule, errorMessage, {\n field,\n value,\n scope: \"global\",\n });\n};\n\n/**\n * Field must be present unless another sibling field equals a specific value\n */\nBaseValidator.prototype.presentUnlessSibling = function (\n field: string,\n value: any,\n errorMessage?: string,\n) {\n return this.addRule(presentUnlessRule, errorMessage, {\n field,\n value,\n scope: \"sibling\",\n });\n};\n\n// ==================== PRESENT: BASED ON FIELD EMPTY STATE ====================\n\n/**\n * Field must be present if another field is empty\n */\nBaseValidator.prototype.presentIfEmpty = function (field: string, errorMessage?: string) {\n return this.addRule(presentIfEmptyRule, errorMessage, {\n field,\n scope: \"global\",\n });\n};\n\n/**\n * Field must be present if another sibling field is empty\n */\nBaseValidator.prototype.presentIfEmptySibling = function (field: string, errorMessage?: string) {\n return this.addRule(presentIfEmptyRule, errorMessage, {\n field,\n scope: \"sibling\",\n });\n};\n\n/**\n * Field must be present if another field is not empty\n */\nBaseValidator.prototype.presentIfNotEmpty = function (field: string, errorMessage?: string) {\n return this.addRule(presentIfNotEmptyRule, errorMessage, {\n field,\n scope: \"global\",\n });\n};\n\n/**\n * Field must be present if another sibling field is not empty\n */\nBaseValidator.prototype.presentIfNotEmptySibling = function (field: string, errorMessage?: string) {\n return this.addRule(presentIfNotEmptyRule, errorMessage, {\n field,\n scope: \"sibling\",\n });\n};\n\n/**\n * Field must be present if another field's value is in the given array\n */\nBaseValidator.prototype.presentIfIn = function (\n field: string,\n values: any[],\n errorMessage?: string,\n) {\n return this.addRule(presentIfInRule, errorMessage, {\n field,\n values,\n scope: \"global\",\n });\n};\n\n/**\n * Field must be present if another sibling field's value is in the given array\n */\nBaseValidator.prototype.presentIfInSibling = function (\n field: string,\n values: any[],\n errorMessage?: string,\n) {\n return this.addRule(presentIfInRule, errorMessage, {\n field,\n values,\n scope: \"sibling\",\n });\n};\n\n/**\n * Field must be present if another field's value is NOT in the given array\n */\nBaseValidator.prototype.presentIfNotIn = function (\n field: string,\n values: any[],\n errorMessage?: string,\n) {\n return this.addRule(presentIfNotInRule, errorMessage, {\n field,\n values,\n scope: \"global\",\n });\n};\n\n/**\n * Field must be present if another sibling field's value is NOT in the given array\n */\nBaseValidator.prototype.presentIfNotInSibling = function (\n field: string,\n values: any[],\n errorMessage?: string,\n) {\n return this.addRule(presentIfNotInRule, errorMessage, {\n field,\n values,\n scope: \"sibling\",\n });\n};\n\n// ==================== PRESENT: BASED ON MULTIPLE FIELDS (ALL) ====================\n\n/**\n * Field must be present if all specified fields exist\n */\nBaseValidator.prototype.presentWithAll = function (fields: string[], errorMessage?: string) {\n return this.addRule(presentWithAllRule, errorMessage, {\n fields,\n scope: \"global\",\n });\n};\n\n/**\n * Field must be present if all specified sibling fields exist\n */\nBaseValidator.prototype.presentWithAllSiblings = function (\n fields: string[],\n errorMessage?: string,\n) {\n return this.addRule(presentWithAllRule, errorMessage, {\n fields,\n scope: \"sibling\",\n });\n};\n\n/**\n * Field must be present if all specified fields are missing\n */\nBaseValidator.prototype.presentWithoutAll = function (fields: string[], errorMessage?: string) {\n return this.addRule(presentWithoutAllRule, errorMessage, {\n fields,\n scope: \"global\",\n });\n};\n\n/**\n * Field must be present if all specified sibling fields are missing\n */\nBaseValidator.prototype.presentWithoutAllSiblings = function (\n fields: string[],\n errorMessage?: string,\n) {\n return this.addRule(presentWithoutAllRule, errorMessage, {\n fields,\n scope: \"sibling\",\n });\n};\n\n// ==================== PRESENT: BASED ON MULTIPLE FIELDS (ANY) ====================\n\n/**\n * Field must be present if any of the specified fields exists\n */\nBaseValidator.prototype.presentWithAny = function (fields: string[], errorMessage?: string) {\n return this.addRule(presentWithAnyRule, errorMessage, {\n fields,\n scope: \"global\",\n });\n};\n\n/**\n * Field must be present if any of the specified sibling fields exists\n */\nBaseValidator.prototype.presentWithAnySiblings = function (\n fields: string[],\n errorMessage?: string,\n) {\n return this.addRule(presentWithAnyRule, errorMessage, {\n fields,\n scope: \"sibling\",\n });\n};\n\n/**\n * Field must be present if any of the specified fields is missing\n */\nBaseValidator.prototype.presentWithoutAny = function (fields: string[], errorMessage?: string) {\n return this.addRule(presentWithoutAnyRule, errorMessage, {\n fields,\n scope: \"global\",\n });\n};\n\n/**\n * Field must be present if any of the specified sibling fields is missing\n */\nBaseValidator.prototype.presentWithoutAnySiblings = function (\n fields: string[],\n errorMessage?: string,\n) {\n return this.addRule(presentWithoutAnyRule, errorMessage, {\n fields,\n scope: \"sibling\",\n });\n};\n"],"mappings":";;;;;;;;;;AA2JA,cAAc,UAAU,cAAc,SAAU,OAAe,cAAuB;CACpF,OAAO,KAAK,QAAQ,iBAAiB,cAAc;EACjD;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,qBAAqB,SAAU,OAAe,cAAuB;CAC3F,OAAO,KAAK,QAAQ,iBAAiB,cAAc;EACjD;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,iBAAiB,SAAU,OAAe,cAAuB;CACvF,OAAO,KAAK,QAAQ,oBAAoB,cAAc;EACpD;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,wBAAwB,SAAU,OAAe,cAAuB;CAC9F,OAAO,KAAK,QAAQ,oBAAoB,cAAc;EACpD;EACA,OAAO;CACT,CAAC;AACH;;;;AAOA,cAAc,UAAU,YAAY,SAAU,OAAe,OAAY,cAAuB;CAC9F,OAAO,KAAK,QAAQ,eAAe,cAAc;EAC/C;EACA;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAA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;;;AAKA,cAAc,UAAU,wBAAwB,SAC9C,OACA,QACA,cACA;CACA,OAAO,KAAK,QAAQ,oBAAoB,cAAc;EACpD;EACA;EACA,OAAO;CACT,CAAC;AACH;;;;AAOA,cAAc,UAAU,iBAAiB,SAAU,QAAkB,cAAuB;CAC1F,OAAO,KAAK,QAAQ,oBAAoB,cAAc;EACpD;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,yBAAyB,SAC/C,QACA,cACA;CACA,OAAO,KAAK,QAAQ,oBAAoB,cAAc;EACpD;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,oBAAoB,SAAU,QAAkB,cAAuB;CAC7F,OAAO,KAAK,QAAQ,uBAAuB,cAAc;EACvD;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,4BAA4B,SAClD,QACA,cACA;CACA,OAAO,KAAK,QAAQ,uBAAuB,cAAc;EACvD;EACA,OAAO;CACT,CAAC;AACH;;;;AAOA,cAAc,UAAU,iBAAiB,SAAU,QAAkB,cAAuB;CAC1F,OAAO,KAAK,QAAQ,oBAAoB,cAAc;EACpD;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,yBAAyB,SAC/C,QACA,cACA;CACA,OAAO,KAAK,QAAQ,oBAAoB,cAAc;EACpD;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,oBAAoB,SAAU,QAAkB,cAAuB;CAC7F,OAAO,KAAK,QAAQ,uBAAuB,cAAc;EACvD;EACA,OAAO;CACT,CAAC;AACH;;;;AAKA,cAAc,UAAU,4BAA4B,SAClD,QACA,cACA;CACA,OAAO,KAAK,QAAQ,uBAAuB,cAAc;EACvD;EACA,OAAO;CACT,CAAC;AACH"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"required-methods.mjs","names":[],"sources":["../../../../../../../../../../seal/src/validators/methods/required-methods.ts"],"sourcesContent":["import {\n requiredIfAllEmptyRule,\n requiredIfAllNotEmptyRule,\n requiredIfAnyEmptyRule,\n requiredIfAnyNotEmptyRule,\n requiredIfEmptyRule,\n requiredIfInRule,\n requiredIfNotEmptyRule,\n requiredIfNotInRule,\n requiredIfRule,\n} from \"../../rules/conditional/required-if-rules\";\nimport { requiredUnlessRule } from \"../../rules/conditional/required-unless-rules\";\nimport { requiredWhenRule } from \"../../rules/conditional/required-when-rule\";\nimport {\n requiredWithAllRule,\n requiredWithAnyRule,\n requiredWithRule,\n} from \"../../rules/conditional/required-with-rules\";\nimport {\n requiredWithoutAllRule,\n requiredWithoutAnyRule,\n requiredWithoutRule,\n} from \"../../rules/conditional/required-without-rules\";\nimport { presentRule, requiredRule } from \"../../rules/core/required\";\nimport type { SchemaContext } from \"../../types\";\nimport { BaseValidator } from \"../base-validator\";\n\n/**\n * Marker re-exported by the validators barrel so the dts bundler keeps this\n * module (and its `declare module` augmentation) in the bundled `.d.ts`.\n * Without a real export, side-effect-only augmentation modules get tree-shaken\n * out of the published types, dropping every chainable rule method.\n */\nexport const requiredMethodsApplied = true;\n\ndeclare module \"../base-validator\" {\n interface BaseValidator {\n /**\n * This value must be present and has a value\n */\n required(errorMessage?: string): this;\n\n /**\n * Value must be present but not necessarily has a value\n */\n present(errorMessage?: string): this;\n\n /**\n * Mark the field as optional, so pass it if it has no value or has a value\n * Because this is the default behavior, this method is just syntactic sugar\n */\n optional(): this & { isOptional: true };\n\n /**\n * Sugar for `.optional().nullable()` — the field may be absent OR null.\n *\n * Brands the return type with both `{ isOptional: true }` and `{ isNullable: true }`\n * so `Infer<>` produces `{ field?: T | null }`.\n *\n * @example\n * v.string().nullish()\n * // type: string | null | undefined\n * // absent → key omitted\n * // null → null\n * // \"x\" → \"x\"\n */\n nullish(): this & { isOptional: true; isNullable: true };\n\n /**\n * Value is required if another field exists\n */\n requiredWith(field: string, errorMessage?: string): this;\n\n /**\n * Value is required if another sibling field exists\n */\n requiredWithSibling(field: string, errorMessage?: string): this;\n\n /**\n * Value is required if another field is missing\n */\n requiredWithout(field: string, errorMessage?: string): this;\n\n /**\n * Value is required if another sibling field is missing\n */\n requiredWithoutSibling(field: string, errorMessage?: string): this;\n\n /**\n * Value is required if another field equals a specific value\n */\n requiredIf(field: string, value: any, errorMessage?: string): this;\n\n /**\n * Value is required if another sibling field equals a specific value\n */\n requiredIfSibling(field: string, value: any, errorMessage?: string): this;\n\n /**\n * Value is required unless another field equals a specific value\n */\n requiredUnless(field: string, value: any, errorMessage?: string): this;\n\n /**\n * Value is required unless another sibling field equals a specific value\n */\n requiredUnlessSibling(field: string, value: any, errorMessage?: string): this;\n\n /**\n * Value is required if another field is empty\n */\n requiredIfEmpty(field: string, errorMessage?: string): this;\n\n /**\n * Value is required if another sibling field is empty\n */\n requiredIfEmptySibling(field: string, errorMessage?: string): this;\n\n /**\n * Value is required if another field is not empty\n */\n requiredIfNotEmpty(field: string, errorMessage?: string): this;\n\n /**\n * Value is required if another sibling field is not empty\n */\n requiredIfNotEmptySibling(field: string, errorMessage?: string): this;\n\n /**\n * Value is required if ALL specified fields are empty\n */\n requiredIfAllEmpty(fields: string[], errorMessage?: string): this;\n\n /**\n * Value is required if ALL specified sibling fields are empty\n */\n requiredIfAllEmptySiblings(fields: string[], errorMessage?: string): this;\n\n /**\n * Value is required if ANY of the specified fields is empty\n */\n requiredIfAnyEmpty(fields: string[], errorMessage?: string): this;\n\n /**\n * Value is required if ANY of the specified sibling fields is empty\n */\n requiredIfAnyEmptySiblings(fields: string[], errorMessage?: string): this;\n\n /**\n * Value is required if ALL specified fields are NOT empty\n */\n requiredIfAllNotEmpty(fields: string[], errorMessage?: string): this;\n\n /**\n * Value is required if ALL specified sibling fields are NOT empty\n */\n requiredIfAllNotEmptySiblings(fields: string[], errorMessage?: string): this;\n\n /**\n * Value is required if ANY of the specified fields is NOT empty\n */\n requiredIfAnyNotEmpty(fields: string[], errorMessage?: string): this;\n\n /**\n * Value is required if ANY of the specified sibling fields is NOT empty\n */\n requiredIfAnyNotEmptySiblings(fields: string[], errorMessage?: string): this;\n\n /**\n * Value is required if another field's value is in the given array\n */\n requiredIfIn(field: string, values: any[], errorMessage?: string): this;\n\n /**\n * Value is required if another sibling field's value is in the given array\n */\n requiredIfInSibling(field: string, values: any[], errorMessage?: string): this;\n\n /**\n * Value is required if another field's value is NOT in the given array\n */\n requiredIfNotIn(field: string, values: any[], errorMessage?: string): this;\n\n /**\n * Value is required if another sibling field's value is NOT in the given array\n */\n requiredIfNotInSibling(field: string, values: any[], errorMessage?: string): this;\n\n /**\n * Value is required if all specified fields exist\n */\n requiredWithAll(fields: string[], errorMessage?: string): this;\n\n /**\n * Value is required if all specified sibling fields exist\n */\n requiredWithAllSiblings(fields: string[], errorMessage?: string): this;\n\n /**\n * Value is required if all specified fields are missing\n */\n requiredWithoutAll(fields: string[], errorMessage?: string): this;\n\n /**\n * Value is required if all specified sibling fields are missing\n */\n requiredWithoutAllSiblings(fields: string[], errorMessage?: string): this;\n\n /**\n * Value is required if any of the specified fields exists\n */\n requiredWithAny(fields: string[], errorMessage?: string): this;\n\n /**\n * Value is required if any of the specified sibling fields exists\n */\n requiredWithAnySiblings(fields: string[], errorMessage?: string): this;\n\n /**\n * Value is required if any of the specified fields is missing\n */\n requiredWithoutAny(fields: string[], errorMessage?: string): this;\n\n /**\n * Value is required if any of the specified sibling fields is missing\n */\n requiredWithoutAnySiblings(fields: string[], errorMessage?: string): this;\n\n /**\n * Make this field required based on a custom callback.\n *\n * The callback receives only the `SchemaContext` (not the value),\n * because \"required\" is about surrounding conditions, not the field itself.\n * Return `true` if the field should be required.\n *\n * @param callback - Receives SchemaContext, returns boolean\n * @param errorMessage - Optional custom error message\n *\n * @example\n * ```ts\n * // Required when email notification is enabled\n * v.string().requiredWhen((context) => {\n * return context.allData.notificationMethod === 'email';\n * })\n *\n * // Required based on multiple conditions\n * v.string().requiredWhen((context) => {\n * const { role, department } = context.allData;\n * return role === 'manager' && department === 'finance';\n * })\n * ```\n */\n requiredWhen(\n callback: (context: SchemaContext) => boolean | Promise<boolean>,\n errorMessage?: string,\n ): this;\n }\n}\n\n// ==================== UNCONDITIONAL STATES ====================\n\n/**\n * This value must be present and has a value\n */\nBaseValidator.prototype.required = function (errorMessage?: string) {\n return this.setRequiredRule(requiredRule, errorMessage);\n};\n\n/**\n * Value must be present but not necessarily has a value\n */\nBaseValidator.prototype.present = function (errorMessage?: string) {\n return this.setRequiredRule(presentRule, errorMessage);\n};\n\n/**\n * Mark the field as optional — it may be absent or empty without validation errors.\n * Clears any previously set required rule.\n *\n * The return type is branded with `{ isOptional: true }` so schema inference\n * can mark this key as optional in the inferred TypeScript type.\n */\nBaseValidator.prototype.optional = function (): BaseValidator & { isOptional: true } {\n const instance = this.instance;\n instance.isOptional = true;\n instance.requiredRule = null;\n return instance as BaseValidator & { isOptional: true };\n};\n\n/**\n * Sugar — equivalent to `.optional().nullable()`.\n */\nBaseValidator.prototype.nullish = function (): BaseValidator & {\n isOptional: true;\n isNullable: true;\n} {\n const instance = this.optional().nullable();\n return instance as BaseValidator & { isOptional: true; isNullable: true };\n};\n\n// ==================== REQUIRED: BASED ON FIELD PRESENCE ====================\n\n/**\n * Value is required if another field exists\n */\nBaseValidator.prototype.requiredWith = function (field: string, errorMessage?: string) {\n return this.setRequiredRule(requiredWithRule, errorMessage, { field, scope: \"global\" });\n};\n\n/**\n * Value is required if another sibling field exists\n */\nBaseValidator.prototype.requiredWithSibling = function (field: string, errorMessage?: string) {\n return this.setRequiredRule(requiredWithRule, errorMessage, { field, scope: \"sibling\" });\n};\n\n/**\n * Value is required if another field is missing\n */\nBaseValidator.prototype.requiredWithout = function (field: string, errorMessage?: string) {\n return this.setRequiredRule(requiredWithoutRule, errorMessage, { field, scope: \"global\" });\n};\n\n/**\n * Value is required if another sibling field is missing\n */\nBaseValidator.prototype.requiredWithoutSibling = function (field: string, errorMessage?: string) {\n return this.setRequiredRule(requiredWithoutRule, errorMessage, { field, scope: \"sibling\" });\n};\n\n// ==================== REQUIRED: BASED ON FIELD VALUE ====================\n\n/**\n * Value is required if another field equals a specific value\n */\nBaseValidator.prototype.requiredIf = function (field: string, value: any, errorMessage?: string) {\n return this.setRequiredRule(requiredIfRule, errorMessage, { field, value, scope: \"global\" });\n};\n\n/**\n * Value is required if another sibling field equals a specific value\n */\nBaseValidator.prototype.requiredIfSibling = function (\n field: string,\n value: any,\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredIfRule, errorMessage, { field, value, scope: \"sibling\" });\n};\n\n/**\n * Value is required unless another field equals a specific value\n */\nBaseValidator.prototype.requiredUnless = function (\n field: string,\n value: any,\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredUnlessRule, errorMessage, { field, value, scope: \"global\" });\n};\n\n/**\n * Value is required unless another sibling field equals a specific value\n */\nBaseValidator.prototype.requiredUnlessSibling = function (\n field: string,\n value: any,\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredUnlessRule, errorMessage, { field, value, scope: \"sibling\" });\n};\n\n// ==================== REQUIRED: BASED ON FIELD EMPTY STATE ====================\n\n/**\n * Value is required if another field is empty\n */\nBaseValidator.prototype.requiredIfEmpty = function (field: string, errorMessage?: string) {\n return this.setRequiredRule(requiredIfEmptyRule, errorMessage, { field, scope: \"global\" });\n};\n\n/**\n * Value is required if another sibling field is empty\n */\nBaseValidator.prototype.requiredIfEmptySibling = function (field: string, errorMessage?: string) {\n return this.setRequiredRule(requiredIfEmptyRule, errorMessage, { field, scope: \"sibling\" });\n};\n\n/**\n * Value is required if another field is not empty\n */\nBaseValidator.prototype.requiredIfNotEmpty = function (field: string, errorMessage?: string) {\n return this.setRequiredRule(requiredIfNotEmptyRule, errorMessage, { field, scope: \"global\" });\n};\n\n/**\n * Value is required if another sibling field is not empty\n */\nBaseValidator.prototype.requiredIfNotEmptySibling = function (\n field: string,\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredIfNotEmptyRule, errorMessage, { field, scope: \"sibling\" });\n};\n\n// ==================== REQUIRED: BASED ON MULTIPLE FIELDS EMPTY STATE ====================\n\n/**\n * Value is required if ALL specified fields are empty\n */\nBaseValidator.prototype.requiredIfAllEmpty = function (fields: string[], errorMessage?: string) {\n return this.setRequiredRule(requiredIfAllEmptyRule, errorMessage, { fields, scope: \"global\" });\n};\n\n/**\n * Value is required if ALL specified sibling fields are empty\n */\nBaseValidator.prototype.requiredIfAllEmptySiblings = function (\n fields: string[],\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredIfAllEmptyRule, errorMessage, { fields, scope: \"sibling\" });\n};\n\n/**\n * Value is required if ANY of the specified fields is empty\n */\nBaseValidator.prototype.requiredIfAnyEmpty = function (fields: string[], errorMessage?: string) {\n return this.setRequiredRule(requiredIfAnyEmptyRule, errorMessage, { fields, scope: \"global\" });\n};\n\n/**\n * Value is required if ANY of the specified sibling fields is empty\n */\nBaseValidator.prototype.requiredIfAnyEmptySiblings = function (\n fields: string[],\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredIfAnyEmptyRule, errorMessage, { fields, scope: \"sibling\" });\n};\n\n/**\n * Value is required if ALL specified fields are NOT empty\n */\nBaseValidator.prototype.requiredIfAllNotEmpty = function (fields: string[], errorMessage?: string) {\n return this.setRequiredRule(requiredIfAllNotEmptyRule, errorMessage, { fields, scope: \"global\" });\n};\n\n/**\n * Value is required if ALL specified sibling fields are NOT empty\n */\nBaseValidator.prototype.requiredIfAllNotEmptySiblings = function (\n fields: string[],\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredIfAllNotEmptyRule, errorMessage, {\n fields,\n scope: \"sibling\",\n });\n};\n\n/**\n * Value is required if ANY of the specified fields is NOT empty\n */\nBaseValidator.prototype.requiredIfAnyNotEmpty = function (fields: string[], errorMessage?: string) {\n return this.setRequiredRule(requiredIfAnyNotEmptyRule, errorMessage, { fields, scope: \"global\" });\n};\n\n/**\n * Value is required if ANY of the specified sibling fields is NOT empty\n */\nBaseValidator.prototype.requiredIfAnyNotEmptySiblings = function (\n fields: string[],\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredIfAnyNotEmptyRule, errorMessage, {\n fields,\n scope: \"sibling\",\n });\n};\n\n/**\n * Value is required if another field's value is in the given array\n */\nBaseValidator.prototype.requiredIfIn = function (\n field: string,\n values: any[],\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredIfInRule, errorMessage, { field, values, scope: \"global\" });\n};\n\n/**\n * Value is required if another sibling field's value is in the given array\n */\nBaseValidator.prototype.requiredIfInSibling = function (\n field: string,\n values: any[],\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredIfInRule, errorMessage, { field, values, scope: \"sibling\" });\n};\n\n/**\n * Value is required if another field's value is NOT in the given array\n */\nBaseValidator.prototype.requiredIfNotIn = function (\n field: string,\n values: any[],\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredIfNotInRule, errorMessage, {\n field,\n values,\n scope: \"global\",\n });\n};\n\n/**\n * Value is required if another sibling field's value is NOT in the given array\n */\nBaseValidator.prototype.requiredIfNotInSibling = function (\n field: string,\n values: any[],\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredIfNotInRule, errorMessage, {\n field,\n values,\n scope: \"sibling\",\n });\n};\n\n// ==================== REQUIRED: BASED ON MULTIPLE FIELDS (ALL) ====================\n\n/**\n * Value is required if all specified fields exist\n */\nBaseValidator.prototype.requiredWithAll = function (fields: string[], errorMessage?: string) {\n return this.setRequiredRule(requiredWithAllRule, errorMessage, { fields, scope: \"global\" });\n};\n\n/**\n * Value is required if all specified sibling fields exist\n */\nBaseValidator.prototype.requiredWithAllSiblings = function (\n fields: string[],\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredWithAllRule, errorMessage, { fields, scope: \"sibling\" });\n};\n\n/**\n * Value is required if all specified fields are missing\n */\nBaseValidator.prototype.requiredWithoutAll = function (fields: string[], errorMessage?: string) {\n return this.setRequiredRule(requiredWithoutAllRule, errorMessage, { fields, scope: \"global\" });\n};\n\n/**\n * Value is required if all specified sibling fields are missing\n */\nBaseValidator.prototype.requiredWithoutAllSiblings = function (\n fields: string[],\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredWithoutAllRule, errorMessage, { fields, scope: \"sibling\" });\n};\n\n// ==================== REQUIRED: BASED ON MULTIPLE FIELDS (ANY) ====================\n\n/**\n * Value is required if any of the specified fields exists\n */\nBaseValidator.prototype.requiredWithAny = function (fields: string[], errorMessage?: string) {\n return this.setRequiredRule(requiredWithAnyRule, errorMessage, { fields, scope: \"global\" });\n};\n\n/**\n * Value is required if any of the specified sibling fields exists\n */\nBaseValidator.prototype.requiredWithAnySiblings = function (\n fields: string[],\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredWithAnyRule, errorMessage, { fields, scope: \"sibling\" });\n};\n\n/**\n * Value is required if any of the specified fields is missing\n */\nBaseValidator.prototype.requiredWithoutAny = function (fields: string[], errorMessage?: string) {\n return this.setRequiredRule(requiredWithoutAnyRule, errorMessage, { fields, scope: \"global\" });\n};\n\n/**\n * Value is required if any of the specified sibling fields is missing\n */\nBaseValidator.prototype.requiredWithoutAnySiblings = function (\n fields: string[],\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredWithoutAnyRule, errorMessage, { fields, scope: \"sibling\" });\n};\n\n// ==================== REQUIRED: BASED ON CUSTOM CALLBACK ====================\n\n/**\n * Make this field required based on a custom callback.\n * Callback receives only SchemaContext — the framework handles empty-value checking.\n */\nBaseValidator.prototype.requiredWhen = function (\n callback: (context: SchemaContext) => boolean | Promise<boolean>,\n errorMessage?: string,\n) {\n return this.setRequiredRule(requiredWhenRule, errorMessage, { callback });\n};\n"],"mappings":";;;;;;;;;;;;AAwQA,cAAc,UAAU,WAAW,SAAU,cAAuB;CAClE,OAAO,KAAK,gBAAgB,cAAc,YAAY;AACxD;;;;AAKA,cAAc,UAAU,UAAU,SAAU,cAAuB;CACjE,OAAO,KAAK,gBAAgB,aAAa,YAAY;AACvD;;;;;;;;AASA,cAAc,UAAU,WAAW,WAAkD;CACnF,MAAM,WAAW,KAAK;CACtB,SAAS,aAAa;CACtB,SAA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;;;;AAOA,cAAc,UAAU,kBAAkB,SAAU,QAAkB,cAAuB;CAC3F,OAAO,KAAK,gBAAgB,qBAAqB,cAAc;EAAE;EAAQ,OAAO;CAAS,CAAC;AAC5F;;;;AAKA,cAAc,UAAU,0BAA0B,SAChD,QACA,cACA;CACA,OAAO,KAAK,gBAAgB,qBAAqB,cAAc;EAAE;EAAQ,OAAO;CAAU,CAAC;AAC7F;;;;AAKA,cAAc,UAAU,qBAAqB,SAAU,QAAkB,cAAuB;CAC9F,OAAO,KAAK,gBAAgB,wBAAwB,cAAc;EAAE;EAAQ,OAAO;CAAS,CAAC;AAC/F;;;;AAKA,cAAc,UAAU,6BAA6B,SACnD,QACA,cACA;CACA,OAAO,KAAK,gBAAgB,wBAAwB,cAAc;EAAE;EAAQ,OAAO;CAAU,CAAC;AAChG;;;;;AAQA,cAAc,UAAU,eAAe,SACrC,UACA,cACA;CACA,OAAO,KAAK,gBAAgB,kBAAkB,cAAc,EAAE,SAAS,CAAC;AAC1E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"number-validator.mjs","names":[],"sources":["../../../../../../../../../seal/src/validators/number-validator.ts"],"sourcesContent":["import {\n absMutator,\n ceilMutator,\n floorMutator,\n numericMutator,\n roundMutator,\n toFixedMutator,\n} from \"../mutators\";\nimport {\n betweenNumbersRule,\n evenRule,\n greaterThanRule,\n lengthRule,\n lessThanRule,\n maxLengthRule,\n maxRule,\n minLengthRule,\n minRule,\n moduloRule,\n negativeRule,\n numberRule,\n oddRule,\n positiveRule,\n} from \"../rules\";\nimport { PrimitiveValidator } from \"./primitive-validator\";\nimport { applyNullable, getRuleOptions } from \"../standard-schema/json-schema\";\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\n\n/**\n * Number validator class - base for Int and Float validators\n */\nexport class NumberValidator extends PrimitiveValidator {\n public constructor(errorMessage?: string) {\n super();\n this.blankIsMissing = true;\n this.addMutableRule(numberRule, errorMessage);\n }\n\n /**\n * Check if value is a number type\n */\n public matchesType(value: any): boolean {\n return typeof value === \"number\" && !isNaN(value);\n }\n\n /**\n * Value must be equal or higher than the given number or field\n * Smart detection: number or field name\n *\n * @category Validation Rule\n */\n public min(min: number | string, errorMessage?: string) {\n return this.addRule(minRule, errorMessage, { min, scope: \"global\" });\n }\n\n /**\n * Value must be equal or less than the given number or field\n * Smart detection: number or field name\n *\n * @category Validation Rule\n */\n public max(max: number | string, errorMessage?: string) {\n return this.addRule(maxRule, errorMessage, { max, scope: \"global\" });\n }\n\n /**\n * Value must be >= sibling field value\n * @category Validation Rule\n */\n public minSibling(field: string, errorMessage?: string) {\n return this.addRule(minRule, errorMessage, { min: field, scope: \"sibling\" });\n }\n\n /**\n * Value must be <= sibling field value\n * @category Validation Rule\n */\n public maxSibling(field: string, errorMessage?: string) {\n return this.addRule(maxRule, errorMessage, { max: field, scope: \"sibling\" });\n }\n\n /**\n * Value must be strictly greater than the given number or field (>)\n * Smart detection: number or field name\n *\n * @category Validation Rule\n */\n public greaterThan(value: number | string, errorMessage?: string) {\n return this.addRule(greaterThanRule, errorMessage, {\n value,\n scope: \"global\",\n });\n }\n\n /**\n * Value must be strictly less than the given number or field (<)\n * Smart detection: number or field name\n *\n * @category Validation Rule\n */\n public lessThan(value: number | string, errorMessage?: string) {\n return this.addRule(lessThanRule, errorMessage, {\n value,\n scope: \"global\",\n });\n }\n\n /**\n * Alias for greaterThan() - shorter syntax\n * @category Validation Rule\n */\n public gt(value: number | string, errorMessage?: string) {\n return this.greaterThan(value, errorMessage);\n }\n\n /**\n * Alias for lessThan() - shorter syntax\n * @category Validation Rule\n */\n public lt(value: number | string, errorMessage?: string) {\n return this.lessThan(value, errorMessage);\n }\n\n /**\n * Value must be > sibling field value\n * @category Validation Rule\n */\n public greaterThanSibling(field: string, errorMessage?: string) {\n return this.addRule(greaterThanRule, errorMessage, {\n value: field,\n scope: \"sibling\",\n });\n }\n\n /**\n * Alias for greaterThanSibling() - shorter syntax\n * @category Validation Rule\n */\n public gtSibling(field: string, errorMessage?: string) {\n return this.greaterThanSibling(field, errorMessage);\n }\n\n /**\n * Value must be < sibling field value\n * @category Validation Rule\n */\n public lessThanSibling(field: string, errorMessage?: string) {\n return this.addRule(lessThanRule, errorMessage, {\n value: field,\n scope: \"sibling\",\n });\n }\n\n /**\n * Alias for lessThanSibling() - shorter syntax\n * @category Validation Rule\n */\n public ltSibling(field: string, errorMessage?: string) {\n return this.lessThanSibling(field, errorMessage);\n }\n\n /** Value must be a modulo of the given number */\n public modulo(value: number, errorMessage?: string) {\n return this.addRule(moduloRule, errorMessage, { value });\n }\n\n /**\n * Alias for modulo() - Value must be divisible by the given number\n */\n public divisibleBy(value: number, errorMessage?: string) {\n return this.modulo(value, errorMessage);\n }\n\n /**\n * Alias for modulo() - Value must be a multiple of the given number\n */\n public multipleOf(value: number, errorMessage?: string) {\n return this.modulo(value, errorMessage);\n }\n\n /**\n * Alias for modulo() - Value must be a multiple of the given number\n */\n public modulusOf(value: number, errorMessage?: string) {\n return this.modulo(value, errorMessage);\n }\n\n /** Accept only numbers higher than 0 */\n public positive(errorMessage?: string) {\n return this.addRule(positiveRule, errorMessage);\n }\n\n /** Accept only negative numbers */\n public negative(errorMessage?: string) {\n return this.addRule(negativeRule, errorMessage);\n }\n\n /** Accept only odd numbers */\n public odd(errorMessage?: string) {\n return this.addRule(oddRule, errorMessage);\n }\n\n /** Accept only even numbers */\n public even(errorMessage?: string) {\n return this.addRule(evenRule, errorMessage);\n }\n\n /**\n * Accept only numbers between the given two numbers or fields (Inclusive)\n * Smart detection: number or field name\n *\n * @category Validation Rule\n */\n public between(min: number | string, max: number | string, errorMessage?: string) {\n return this.addRule(betweenNumbersRule, errorMessage, {\n min,\n max,\n scope: \"global\",\n });\n }\n\n /**\n * Value must be between sibling field values\n * @category Validation Rule\n */\n public betweenSibling(minField: string, maxField: string, errorMessage?: string) {\n return this.addRule(betweenNumbersRule, errorMessage, {\n min: minField,\n max: maxField,\n scope: \"sibling\",\n });\n }\n\n // Enum and value membership methods are inherited from PrimitiveValidator.\n\n /**\n * Value (as a string) must be exactly this many characters.\n * Useful for fixed-format numeric codes (e.g. 4-digit PIN).\n */\n public length(length: number, errorMessage?: string) {\n return this.addRule(lengthRule, errorMessage, { length });\n }\n\n /** Value (as string representation) length must be ≥ min */\n public minLength(length: number, errorMessage?: string) {\n return this.addRule(minLengthRule, errorMessage, { minLength: length });\n }\n\n /** Value (as string representation) length must be ≤ max */\n public maxLength(length: number, errorMessage?: string) {\n return this.addRule(maxLengthRule, errorMessage, { maxLength: length });\n }\n\n // Mutators\n\n /**\n * Convert value to its absolute value\n */\n public abs() {\n return this.addMutator(absMutator);\n }\n\n /**\n * Round value up to the nearest integer\n */\n public ceil() {\n return this.addMutator(ceilMutator);\n }\n\n /**\n * Round value down to the nearest integer\n */\n public floor() {\n return this.addMutator(floorMutator);\n }\n\n /**\n * Round value to the nearest integer or specified decimals\n */\n public round(decimals = 0) {\n return this.addMutator(roundMutator, { decimals });\n }\n\n /**\n * Round to a fixed number of decimal places, keeping the value a **number**.\n *\n * `v.number().toFixed(2)` on `3.14159` yields `3.14`, not `\"3.14\"` — a number\n * schema has to output a number, or its own type rule rejects the result.\n * Format to a fixed-point *string* at the presentation edge instead.\n *\n * @example\n * v.number().toFixed(2) // 3.14159 → 3.14\n */\n public toFixed(decimals = 2) {\n return this.addMutator(toFixedMutator, { decimals });\n }\n\n /**\n * Opt in to coercion: a numeric-shaped string is converted to a number\n * **before** the type rules run; any other value passes through unchanged\n * so bad input still fails the type rule.\n *\n * Strictness is preserved — coercion only fixes the string *representation*,\n * not the value's shape. `v.int().coerce()` turns `\"5\"` into `5` (valid) but\n * `\"5.5\"` into `5.5`, which still fails the integer rule. Number validators\n * do **not** coerce by default; this only takes effect when explicitly chained.\n *\n * The output type is unchanged (`Infer<>` keys off the validator class), so\n * `v.int().coerce()` still infers `number`.\n *\n * @example\n * v.int().coerce() // \"5\" → 5 (valid); \"5.5\" → 5.5 (invalid); \"abc\" → invalid\n * v.number().coerce() // \"5.5\" → 5.5 (valid)\n */\n public coerce() {\n return this.addMutator(numericMutator) as this & { isCoerced: true };\n }\n\n /**\n * @inheritdoc\n *\n * Returns `{ type: \"number\" }` with numeric constraint keywords.\n * IntValidator overrides `type` to `\"integer\"`.\n *\n * @note Sibling-scoped rules (minSibling, maxSibling, etc.) are not representable\n * in JSON Schema and are silently omitted.\n *\n * @example\n * ```ts\n * v.number().min(0).max(100).toJsonSchema(\"draft-2020-12\")\n * // → { type: \"number\", minimum: 0, maximum: 100 }\n * ```\n */\n public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n return this.buildNumberJsonSchema(\"number\", target);\n }\n\n /**\n * Shared logic for number/integer JSON Schema generation.\n * Called by NumberValidator.toJsonSchema() (→ type: \"number\")\n * and IntValidator.toJsonSchema() (→ type: \"integer\").\n */\n protected buildNumberJsonSchema(\n type: \"number\" | \"integer\",\n target: JsonSchemaTarget,\n ): JsonSchemaResult {\n const schema: JsonSchemaResult = { type };\n\n // minimum (inclusive)\n const minOpts = getRuleOptions(this.rules, \"min\");\n if (minOpts?.min !== undefined && typeof minOpts.min === \"number\") {\n schema.minimum = minOpts.min;\n }\n\n // maximum (inclusive)\n const maxOpts = getRuleOptions(this.rules, \"max\");\n if (maxOpts?.max !== undefined && typeof maxOpts.max === \"number\") {\n schema.maximum = maxOpts.max;\n }\n\n // between (inclusive range)\n const betweenOpts = getRuleOptions(this.rules, \"betweenNumbers\");\n if (betweenOpts) {\n if (typeof betweenOpts.min === \"number\") schema.minimum = betweenOpts.min;\n if (typeof betweenOpts.max === \"number\") schema.maximum = betweenOpts.max;\n }\n\n // greaterThan (>) → exclusiveMinimum\n const gtOpts = getRuleOptions(this.rules, \"greaterThan\");\n if (gtOpts?.value !== undefined && typeof gtOpts.value === \"number\") {\n if (target === \"draft-07\") {\n schema.minimum = gtOpts.value;\n schema.exclusiveMinimum = true;\n } else {\n schema.exclusiveMinimum = gtOpts.value;\n }\n }\n\n // lessThan (<) → exclusiveMaximum\n const ltOpts = getRuleOptions(this.rules, \"lessThan\");\n if (ltOpts?.value !== undefined && typeof ltOpts.value === \"number\") {\n if (target === \"draft-07\") {\n schema.maximum = ltOpts.value;\n schema.exclusiveMaximum = true;\n } else {\n schema.exclusiveMaximum = ltOpts.value;\n }\n }\n\n // multipleOf / modulo\n const moduloOpts = getRuleOptions(this.rules, \"modulo\");\n if (moduloOpts?.value !== undefined && typeof moduloOpts.value === \"number\") {\n schema.multipleOf = moduloOpts.value;\n }\n\n // enum (from PrimitiveValidator.in / .enum)\n const inOpts = getRuleOptions(this.rules, \"in\");\n if (inOpts?.values && Array.isArray(inOpts.values)) {\n schema.enum = inOpts.values;\n }\n\n if (this.isNullable) applyNullable(schema, target);\n\n return schema;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AA+BA,IAAa,kBAAb,cAAqC,mBAAmB;CACtD,AAAO,YAAY,cAAuB;EACxC,MAAM;EACN,KAAK,iBAAiB;EACtB,KAAK,eAAe,YAAY,YAAY;CAC9C;;;;CAKA,AAAO,YAAY,OAAqB;EACtC,OAAO,OAAO,UAAU,YAAY,CAAC,MAAM,KAAK;CAClD;;;;;;;CAQA,AAAO,IAAI,KAAsB,cAAuB;EACtD,OAAO,KAAK,QAAQ,SAAS,cAAc;GAAE;GAAK,OAAO;EAAS,CAAC;CACrE;;;;;;;CAQA,AAAO,IAAI,KAAsB,cAAuB;EACtD,OAAO,KAAK,QAAQ,SAAS,cAAc;GAAE;GAAK,OAAO;EAAS,CAAC;CACrE;;;;;CAMA,AAAO,WAAW,OAAe,cAAuB;EACtD,OAAO,KAAK,QAAQ,SAAS,cAAc;GAAE,KAAK;GAAO,OAAO;EAAU,CAAC;CAC7E;;;;;CAMA,AAAO,WAAW,OAAe,cAAuB;EACtD,OAAO,KAAK,QAAQ,SAAS,cAAc;GAAE,KAAK;GAAO,OAAO;EAAU,CAAC;CAC7E;;;;;;;CAQA,AAAO,YAAY,OA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","names":[],"sources":["../../../../../../../../../seal/src/validators/numeric-validator.ts"],"sourcesContent":["import { isNumeric } from \"@mongez/supportive-is\";\nimport { numericMutator } from \"../mutators/number-mutators\";\nimport { NumberValidator } from \"./number-validator\";\n\n/**\n * Numeric validator class - base for Int and Float validators either as number or string\n */\nexport class NumericValidator extends NumberValidator {\n /**\n * Constructor\n */\n public constructor(errorMessage?: string) {\n super(errorMessage);\n this.addMutableMutator(numericMutator);\n }\n\n /**\n * Check if value is a numeric type\n */\n public matchesType(value: any): boolean {\n return isNumeric(value);\n }\n}\n"],"mappings":";;;;;;;;AAOA,IAAa,mBAAb,cAAsC,gBAAgB;;;;CAIpD,AAAO,YAAY,cAAuB;EACxC,MAAM,YAAY;EAClB,KAAK,kBAAkB,cAAc;CACvC;;;;CAKA,AAAO,YAAY,OAAqB;EACtC,OAAO,UAAU,KAAK;CACxB;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object-validator.mjs","names":[],"sources":["../../../../../../../../../seal/src/validators/object-validator.ts"],"sourcesContent":["import { except } from \"@mongez/reinforcements\";\nimport { isPlainObject } from \"@mongez/supportive-is\";\nimport { setKeyPath } from \"../helpers/path-helpers\";\nimport { objectTrimMutator, stripUnknownMutator } from \"../mutators/object-mutators\";\nimport { objectRule } from \"../rules/common/type-rules\";\nimport { unknownKeyRule } from \"../rules/common/unknown-key\";\nimport type { JsonSchemaResult, JsonSchemaTarget } from \"../standard-schema/json-schema\";\nimport { applyNullable, wrapNullableStrict } from \"../standard-schema/json-schema\";\nimport type { Schema, SchemaContext, ValidationResult } from \"../types\";\nimport type { InferInputObjectShape, InferOutputObjectShape } from \"../types/inference-types\";\nimport { BaseValidator } from \"./base-validator\";\nimport { ComputedValidator } from \"./computed-validator\";\n\n/**\n * Object validator class with generic schema type for proper type inference.\n *\n * Threads two distinct inferred shapes into `BaseValidator`'s `TInput`/`TOutput`:\n *\n * - `TInput` = `InferInputObjectShape<TSchema>` — what `~standard.validate()`\n * accepts (caller's pre-validation payload; defaults/catches make\n * keys optional)\n * - `TOutput` = `InferOutputObjectShape<TSchema>` — what `~standard.validate()`\n * returns on success (post-default, post-catch shape; guaranteed\n * keys are required)\n *\n * Both helpers are used directly (not the full `Infer.*` walker) to avoid a\n * recursive class-base evaluation that would otherwise occur when the\n * brand-aware widening tries to inspect the class type.\n */\nexport class ObjectValidator<TSchema extends Schema = Schema> extends BaseValidator<\n InferInputObjectShape<TSchema>,\n InferOutputObjectShape<TSchema>\n> {\n protected shouldAllowUnknown = false;\n protected allowedKeys: string[] = [];\n protected hasUnknownKeyRule = false;\n\n public constructor(\n public schema: TSchema,\n errorMessage?: string,\n ) {\n super();\n this.addMutableRule(objectRule, errorMessage);\n }\n\n /**\n * Check if value is an object type (plain object, not array or date)\n */\n public matchesType(value: any): boolean {\n return isPlainObject(value);\n }\n\n /** Strip unknown keys from the data */\n public stripUnknown() {\n const validator = this.instance;\n return validator.addMutator(stripUnknownMutator, {\n get allowedKeys() {\n return validator.allowedKeys;\n },\n });\n }\n\n /** Add list of allowed keys that could be in the data but not necessarily validated */\n public allow(...keys: string[]) {\n const validator = this.instance;\n validator.allowedKeys.push(...keys);\n return validator;\n }\n\n /** Trim values of the object properties */\n public trim(recursive = true) {\n const validator = this.instance;\n return validator.addMutator(objectTrimMutator, { recursive });\n }\n\n /** Whether to allow unknown properties\n * Please note it will allow only unknown direct children keys, not nested children keys\n */\n public allowUnknown(allow = true) {\n const validator = this.instance;\n validator.shouldAllowUnknown = allow;\n return validator;\n }\n\n /**\n * Create a copy of this object validator with the same configuration\n * Copies schema, rules, mutators, transformers, and object-specific settings\n *\n * @returns A new ObjectValidator instance with copied configuration\n *\n * @example\n * ```ts\n * const baseUser = v.object({ name: v.string() }).allowUnknown();\n * const userCopy = baseUser.clone();\n * // userCopy has the same schema and allowUnknown setting\n * ```\n */\n public override clone(keys?: string[]): this {\n // Get cloned instance with all BaseValidator properties\n const cloned = super.clone();\n\n // Clone schema with deep copy of validators\n const newSchema = {} as TSchema;\n for (const [key, validator] of Object.entries(this.schema)) {\n if (keys && !keys.includes(key)) continue;\n (newSchema as Schema)[key] = validator.clone();\n }\n\n cloned.schema = newSchema;\n\n // Add ObjectValidator-specific properties\n cloned.shouldAllowUnknown = this.shouldAllowUnknown;\n cloned.allowedKeys = [...this.allowedKeys];\n // NOTE: hasUnknownKeyRule is intentionally NOT copied.\n // Each clone must add its own unknownKeyRule on first validate()\n // so it holds references to its own schema/allowedKeys, not the original's.\n\n return cloned;\n }\n\n /**\n * Extend this schema with additional fields\n * Clones the current validator and adds new fields to the schema\n * **Keeps original configuration** (allowUnknown, stripUnknown, etc.)\n *\n * If an ObjectValidator is provided, only its schema is used - its configuration is ignored.\n * This is useful for creating reusable field collections that can be added to different schemas.\n *\n * @param schemaOrValidator - Plain schema object or ObjectValidator to extend with\n * @returns A new ObjectValidator with merged schema and original configuration\n *\n * @example\n * ```ts\n * // Extend with plain schema\n * const baseUser = v.object({\n * name: v.string().required(),\n * email: v.string().email().required()\n * }).allowUnknown();\n *\n * const adminUser = baseUser.extend({\n * role: v.string().in(['admin', 'superadmin']).required()\n * });\n * // adminUser has: name, email, role\n * // adminUser keeps: allowUnknown() from base ✅\n *\n * // Extend with ObjectValidator (only schema is used)\n * const auditFields = v.object({\n * createdAt: v.date().required(),\n * updatedAt: v.date().required()\n * }).stripUnknown(); // This config is ignored!\n *\n * const fullUser = baseUser.extend(auditFields);\n * // fullUser has: name, email, createdAt, updatedAt\n * // fullUser keeps: allowUnknown() from base (NOT stripUnknown from auditFields) ✅\n *\n * // Chain multiple extends\n * const complexSchema = baseUser\n * .extend(auditFields)\n * .extend({ metadata: v.object({}) });\n * ```\n */\n public extend<TExtension extends Schema>(\n schemaOrValidator: TExtension | ObjectValidator<TExtension>,\n ): ObjectValidator<TSchema & TExtension> {\n // Clone current validator to preserve original\n const extended = this.clone() as any;\n\n // Extract schema from parameter\n const schemaToAdd =\n schemaOrValidator instanceof ObjectValidator ? schemaOrValidator.schema : schemaOrValidator;\n\n // Merge schemas with cloned validators (later fields override earlier ones)\n for (const [key, validator] of Object.entries(schemaToAdd)) {\n (extended.schema as Schema)[key] = validator.clone();\n }\n\n return extended as ObjectValidator<TSchema & TExtension>;\n }\n\n /**\n * Merge with another ObjectValidator\n * Clones current validator, merges schemas, and **overrides configuration** with other validator's config\n *\n * Unlike extend(), merge() combines both schemas AND configurations.\n * The other validator's configuration (allowUnknown, stripUnknown, etc.) takes precedence.\n *\n * @param validator - Another ObjectValidator to merge with\n * @returns A new ObjectValidator with merged schema and configuration\n *\n * @example\n * ```ts\n * const baseUser = v.object({\n * name: v.string().required()\n * }).allowUnknown();\n *\n * const timestamps = v.object({\n * createdAt: v.date().required(),\n * updatedAt: v.date().required()\n * }).stripUnknown();\n *\n * const merged = baseUser.merge(timestamps);\n * // merged has: name, createdAt, updatedAt\n * // merged config: stripUnknown() from timestamps (overrides allowUnknown) ✅\n *\n * // Chain multiple merges\n * const full = baseUser.merge(timestamps).merge(softDeleteSchema);\n * ```\n */\n public merge<TMerge extends Schema>(\n validator: ObjectValidator<TMerge>,\n ): ObjectValidator<TSchema & TMerge> {\n // Clone current validator\n const merged = this.clone() as any;\n\n // Merge schemas with cloned validators (later fields override earlier ones)\n for (const [key, schemaValidator] of Object.entries(validator.schema)) {\n (merged.schema as Schema)[key] = schemaValidator.clone();\n }\n\n // Override configuration with other validator's config\n merged.shouldAllowUnknown = validator.shouldAllowUnknown;\n merged.allowedKeys = [...merged.allowedKeys, ...validator.allowedKeys];\n\n // Append rules, mutators, transformers from other validator\n merged.rules.push(...validator.rules);\n merged.mutators.push(...validator.mutators);\n merged.dataTransformers.push(...validator.dataTransformers);\n\n // Merge attributes text (later wins)\n merged.attributesText = {\n ...merged.attributesText,\n ...validator.attributesText,\n };\n\n merged.translatedAttributes = {\n ...merged.translatedAttributes,\n ...validator.translatedAttributes,\n };\n\n return merged as ObjectValidator<TSchema & TMerge>;\n }\n\n /**\n * Create a new schema with only the specified fields\n * Clones the current validator and keeps only the selected fields\n * **Preserves all configuration** (allowUnknown, stripUnknown, etc.)\n *\n * @param keys - Field names to keep in the schema\n * @returns A new ObjectValidator with only the picked fields\n *\n * @example\n * ```ts\n * const fullUser = v.object({\n * id: v.int().required(),\n * name: v.string().required(),\n * email: v.string().email().required(),\n * password: v.string().required(),\n * role: v.string()\n * }).allowUnknown();\n *\n * // For login - only need email and password\n * const loginSchema = fullUser.pick('email', 'password');\n * // loginSchema has: { email, password }\n * // loginSchema keeps: allowUnknown() ✅\n *\n * // For public profile\n * const publicSchema = fullUser.pick('id', 'name', 'role');\n * // publicSchema has: { id, name, role }\n * ```\n */\n public pick<K extends keyof TSchema>(...keys: K[]): ObjectValidator<Pick<TSchema, K>> {\n // Clone current validator\n const picked = this.clone() as any;\n\n // Create new schema with only picked keys\n const newSchema = {} as Pick<TSchema, K>;\n for (const key of keys) {\n if (key in picked.schema) {\n (newSchema as any)[key] = picked.schema[key];\n }\n }\n\n picked.schema = newSchema;\n\n return picked as ObjectValidator<Pick<TSchema, K>>;\n }\n\n /**\n * Mark all or the given schema fields as optional\n */\n public partial<K extends keyof TSchema>(...keys: K[]) {\n const validationSchema = this.clone();\n\n if (keys.length === 0) {\n keys = Object.keys(validationSchema.schema) as K[];\n }\n\n for (const [key, validator] of Object.entries(validationSchema.schema)) {\n if (keys.length === 0 || keys.includes(key as K)) {\n (validationSchema.schema as Schema)[key] = validator.optional();\n }\n }\n\n return validationSchema;\n }\n\n /**\n * Make the all or the given fields as required\n */\n public requiredFields<K extends keyof TSchema>(...keys: K[]) {\n const validationSchema = this.clone();\n\n if (keys.length === 0) {\n keys = Object.keys(validationSchema.schema) as K[];\n }\n\n for (const [key, validator] of Object.entries(validationSchema.schema)) {\n if (keys.length === 0 || keys.includes(key as K)) {\n (validationSchema.schema as Schema)[key] = validator.required();\n }\n }\n\n return validationSchema;\n }\n\n /**\n * Create a new schema excluding the specified fields\n * Clones the current validator and removes the specified fields\n * **Preserves all configuration** (allowUnknown, stripUnknown, etc.)\n *\n * @param keys - Field names to exclude from the schema\n * @returns A new ObjectValidator without the excluded fields\n *\n * @example\n * ```ts\n * const fullUser = v.object({\n * id: v.int().required(),\n * name: v.string().required(),\n * email: v.string().email().required(),\n * password: v.string().required(),\n * role: v.string()\n * }).allowUnknown();\n *\n * // For updates - exclude id\n * const updateSchema = fullUser.without('id');\n * // updateSchema has: { name, email, password, role }\n * // updateSchema keeps: allowUnknown() ✅\n *\n * // For public API - exclude sensitive fields\n * const publicSchema = fullUser.without('password', 'role');\n * // publicSchema has: { id, name, email }\n *\n * // Combine with other methods\n * const patchSchema = fullUser.without('id', 'password');\n * // patchSchema has: { name, email, role }\n * ```\n */\n public without<K extends keyof TSchema>(...keys: K[]): ObjectValidator<Omit<TSchema, K>> {\n // Clone current validator\n const filtered = this.clone() as any;\n\n // Create new schema excluding specified keys\n const newSchema = {} as Omit<TSchema, K>;\n for (const key in filtered.schema) {\n if (!keys.includes(key as any)) {\n (newSchema as any)[key] = filtered.schema[key];\n }\n }\n\n filtered.schema = newSchema;\n\n return filtered as ObjectValidator<Omit<TSchema, K>>;\n }\n\n /** Mutate the data */\n public mutate(data: any, context: SchemaContext) {\n if (!isPlainObject(data)) return data;\n return super.mutate({ ...data }, context);\n }\n\n /** Validate the data */\n public async validate(\n data: any,\n context: SchemaContext = { path: \"\" } as SchemaContext,\n ): Promise<ValidationResult> {\n context.schema = this.schema;\n const mutatedData = await this.mutate(data, context);\n\n // Check for unknown properties\n if (this.shouldAllowUnknown === false && !this.hasUnknownKeyRule) {\n this.hasUnknownKeyRule = true;\n const rule = this.addMutableRule(unknownKeyRule, undefined, {\n allowedKeys: this.allowedKeys,\n schema: this.schema,\n });\n\n this.setRuleAttributesList(rule);\n }\n\n const result = await super.validate(mutatedData, context);\n\n if (result.isValid === false) return result;\n\n // Absent (no default) or null (nullable) inputs short-circuit here —\n // BaseValidator.validate already resolved the outcome, so recursing into\n // the shape below would wrongly re-run required checks against `undefined`.\n if (mutatedData === undefined || mutatedData === null) return result;\n\n // ═══════════════════════════════════════════════════════════\n // PHASE 1: Validate user input fields (skip computed/managed)\n // ═══════════════════════════════════════════════════════════\n const errors: ValidationResult[\"errors\"] = [];\n const validatedData: any = {};\n\n // Child validators settle in completion order, so errors are collected per\n // field and flattened in declared schema order for deterministic output.\n const fieldErrors: Array<ValidationResult[\"errors\"]> = [];\n\n const userInputEntries = Object.entries(this.schema).filter(\n ([, validator]) => !this.isComputedValidator(validator),\n );\n\n const validationPromises = userInputEntries.map(async ([key, validator], index) => {\n const value =\n mutatedData?.[key] !== undefined ? mutatedData[key] : validator.getDefaultValue();\n\n const childContext: SchemaContext = {\n ...context,\n parent: mutatedData,\n value,\n key,\n path: setKeyPath(context.path, key),\n };\n\n const childResult = await validator.validate(value, childContext);\n\n // Only include in validated data if not omitted\n if (childResult.data !== undefined && !validator.isOmitted()) {\n validatedData[key] = childResult.data;\n }\n\n if (childResult.isValid === false) {\n fieldErrors[index] = childResult.errors;\n }\n });\n\n await Promise.all(validationPromises);\n\n for (const childErrors of fieldErrors) {\n if (childErrors) {\n errors.push(...childErrors);\n }\n }\n\n // If Phase 1 failed, return early\n if (errors.length > 0) {\n return {\n isValid: false,\n errors,\n data: undefined,\n };\n }\n\n // ═══════════════════════════════════════════════════════════\n // PHASE 2: Execute computed/managed fields with validated data\n // ═══════════════════════════════════════════════════════════\n const computedFields = this.getComputedFields();\n\n const computedErrors: Array<ValidationResult[\"errors\"]> = [];\n\n const computedPromises = Object.entries(computedFields).map(async ([key, validator], index) => {\n const childContext: SchemaContext = {\n ...context,\n parent: validatedData,\n value: undefined, // Computed fields don't have input value\n };\n\n // Execute computed callback with validated data\n const childResult = await validator.validate(validatedData, childContext);\n\n // Only include in final data if not omitted\n if (childResult.data !== undefined && !validator.isOmitted()) {\n validatedData[key] = childResult.data;\n }\n\n if (childResult.isValid === false) {\n computedErrors[index] = childResult.errors;\n }\n });\n\n await Promise.all(computedPromises);\n\n for (const childErrors of computedErrors) {\n if (childErrors) {\n errors.push(...childErrors);\n }\n }\n\n // If Phase 2 failed, return early\n if (errors.length > 0) {\n return {\n isValid: false,\n errors,\n data: undefined,\n };\n }\n\n // Fields were assigned in the order their validators finished; re-emit\n // them in declared schema order so the output shape is deterministic.\n const orderedData: any = {};\n\n for (const key of Object.keys(this.schema)) {\n if (key in validatedData) {\n orderedData[key] = validatedData[key];\n }\n }\n\n // Remove undefined values\n const cleanedData = removeUndefinedValues(orderedData);\n\n const transformedData = await this.startTransformationPipeline(cleanedData, context);\n\n const output =\n this.shouldAllowUnknown === false\n ? transformedData\n : {\n ...transformedData,\n ...except(mutatedData, Object.keys(this.schema)),\n };\n\n return {\n isValid: true,\n errors: [],\n data: output,\n };\n }\n\n /**\n * Check if a validator is a computed or managed field\n * ManagedValidator extends ComputedValidator, so instanceof catches both\n */\n private isComputedValidator(validator: BaseValidator): boolean {\n return validator instanceof ComputedValidator;\n }\n\n /**\n * Get all computed/managed fields from the schema\n */\n private getComputedFields(): Record<string, ComputedValidator> {\n const computed: Record<string, ComputedValidator> = {};\n\n for (const [key, validator] of Object.entries(this.schema)) {\n if (validator instanceof ComputedValidator) {\n computed[key] = validator;\n }\n }\n\n return computed;\n }\n\n /**\n * @inheritdoc\n *\n * Recursively generates JSON Schema for all input fields in the schema.\n * Computed/managed fields are skipped — they have no input representation.\n *\n * **Standard targets** (`draft-2020-12`, `draft-07`, `openapi-3.0`):\n * - Fields marked `.optional()` are excluded from `required`.\n *\n * **`openai-strict` target** (OpenAI Structured Outputs):\n * - ALL fields appear in `required` — OpenAI rejects schemas with optional fields.\n * - Optional fields are instead expressed as nullable types:\n * `{ type: [\"string\", \"null\"] }` so the model can output `null` for them.\n * - Recursively applies `openai-strict` to all nested objects.\n *\n * @example\n * ```ts\n * v.object({\n * name: v.string().required(),\n * age: v.int().optional(),\n * }).toJsonSchema(\"draft-2020-12\")\n * // → { type: \"object\",\n * // properties: { name: { type: \"string\" }, age: { type: \"integer\" } },\n * // required: [\"name\"], additionalProperties: false }\n *\n * v.object({\n * name: v.string().required(),\n * age: v.int().optional(),\n * }).toJsonSchema(\"openai-strict\")\n * // → { type: \"object\",\n * // properties: { name: { type: \"string\" }, age: { type: [\"integer\", \"null\"] } },\n * // required: [\"name\", \"age\"], ← all fields\n * // additionalProperties: false }\n * ```\n */\n public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n const properties: Record<string, JsonSchemaResult> = {};\n const required: string[] = [];\n const isOpenAIStrict = target === \"openai-strict\";\n\n for (const [key, validator] of Object.entries(this.schema)) {\n // Skip computed/managed — runtime-only, no input schema\n if (validator instanceof ComputedValidator) continue;\n\n let fieldSchema = validator.toJsonSchema(target);\n\n if (isOpenAIStrict) {\n // OpenAI strict: every field must be in required.\n // Optional fields are expressed as nullable rather than absent.\n if (validator.isOptional) {\n fieldSchema = wrapNullableStrict(fieldSchema);\n }\n required.push(key);\n } else {\n // Standard JSON Schema: only non-optional fields go in required\n if (!validator.isOptional) {\n required.push(key);\n }\n }\n\n properties[key] = fieldSchema;\n }\n\n const schema: JsonSchemaResult = { type: \"object\", properties };\n\n if (required.length > 0) schema.required = required;\n if (!this.shouldAllowUnknown) schema.additionalProperties = false;\n if (this.isNullable) applyNullable(schema, target);\n\n return schema;\n }\n}\n\n/** Recursively remove undefined values from an object */\nfunction removeUndefinedValues(obj: any, visited = new WeakMap<object, any>()): any {\n // Handle primitives and null\n if (obj === null) {\n return obj;\n }\n\n // Handle arrays\n if (Array.isArray(obj)) {\n return obj.map((item) => removeUndefinedValues(item, visited));\n }\n\n // Skip non-plain objects (class instances, Dates, Buffers, etc.)\n if (!isPlainObject(obj)) {\n return obj;\n }\n\n // Handle circular references - return already processed result\n if (visited.has(obj)) {\n return visited.get(obj);\n }\n\n // Process plain objects\n const result: any = {};\n visited.set(obj, result); // Mark as processing BEFORE recursion\n\n for (const [key, value] of Object.entries(obj)) {\n if (value !== undefined) {\n result[key] = removeUndefinedValues(value, visited);\n }\n }\n\n return result;\n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AAK,oBAAoB,OAAO,uBAAuB;EAC5D,IAAI,KAAK,YAAY,cAAc,QAAQ,MAAM;EAEjD,OAAO;CACT;AACF;;AAGA,SAAS,sBAAsB,KAAU,0BAAU,IAAI,QAAqB,GAAQ;CAElF,IAAI,QAAQ,MACV,OAAO;CAIT,IAAI,MAAM,QAAQ,GAAG,GACnB,OAAO,IAAI,KAAK,SAAS,sBAAsB,MAAM,OAAO,CAAC;CAI/D,IAAI,CAAC,cAAc,GAAG,GACpB,OAAO;CAIT,IAAI,QAAQ,IAAI,GAAG,GACjB,OAAO,QAAQ,IAAI,GAAG;CAIxB,MAAM,SAAc,CAAC;CACrB,QAAQ,IAAI,KAAK,MAAM;CAEvB,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,GAAG,GAC3C,IAAI,UAAU,QACZ,OAAO,OAAO,sBAAsB,OAAO,OAAO;CAItD,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"primitive-validator.mjs","names":[],"sources":["../../../../../../../../../seal/src/validators/primitive-validator.ts"],"sourcesContent":["import { allowedValuesRule, enumRule, inRule, notAllowedValuesRule } from \"../rules/common/enum\";\nimport { BaseValidator } from \"./base-validator\";\n\n/**\n * Abstract base validator for primitive-typed fields (string, number, boolean).\n *\n * Provides value-membership rules that are meaningful for any single primitive value\n * but not for complex structures (object, array).\n *\n * Do NOT expose this on the `v` factory — it is an inheritance-only base class.\n *\n * Hierarchy:\n * BaseValidator\n * └── PrimitiveValidator ← enum, in, oneOf, allowsOnly, forbids, notIn\n * ├── StringValidator\n * ├── NumberValidator\n * │ └── FloatValidator\n * ├── BooleanValidator\n * └── ScalarValidator (extends PrimitiveValidator, adds asNumber/asString/accepted/declined)\n *\n * @example\n * class MyValidator extends PrimitiveValidator {\n * // inherits: in(), forbids(), enum(), oneOf(), allowsOnly(), notIn()\n * }\n */\nexport abstract class PrimitiveValidator extends BaseValidator {\n /**\n * Value must be one of the enum's values\n *\n * @example\n * v.string().enum(Direction) // Direction is a TS enum\n */\n public enum(values: any, errorMessage?: string) {\n return this.addRule(enumRule, errorMessage, { enum: Object.values(values) });\n }\n\n /**\n * Value must be one of the given values\n *\n * @example\n * v.string().in([\"admin\", \"user\", \"guest\"])\n * v.number().in([1, 2, 3])\n */\n public in(values: any[], errorMessage?: string) {\n return this.addRule(inRule, errorMessage, { values });\n }\n\n /**\n * Alias for `in()`\n *\n * @example\n * v.string().oneOf([\"active\", \"inactive\"])\n */\n public oneOf(values: any[], errorMessage?: string) {\n return this.in(values, errorMessage);\n }\n\n /**\n * Value must be one of the allowed values (stricter variant)\n *\n * @example\n * v.string().allowsOnly([\"yes\", \"no\"])\n */\n public allowsOnly(values: any[], errorMessage?: string) {\n return this.addRule(allowedValuesRule, errorMessage, { allowedValues: values });\n }\n\n /**\n * Value must NOT be one of the given values\n *\n * @example\n * v.string().forbids([\"banned\", \"blacklisted\"])\n * v.number().forbids([0, -1])\n */\n public forbids(values: any[], errorMessage?: string) {\n return this.addRule(notAllowedValuesRule, errorMessage, { notAllowedValues: values });\n }\n\n /**\n * Alias for `forbids()`\n *\n * @example\n * v.string().notIn([\"OK\", \"NOT OK\"])\n */\n public notIn(values: any[], errorMessage?: string) {\n return this.forbids(values, errorMessage);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAsB,qBAAtB,cAAiD,cAAc;;;;;;;CAO7D,AAAO,KAAK,QAAa,cAAuB;EAC9C,OAAO,KAAK,QAAQ,UAAU,cAAc,EAAE,MAAM,OAAO,OAAO,MAAM,EAAE,CAAC;CAC7E;;;;;;;;CASA,AAAO,GAAG,QAAe,cAAuB;EAC9C,OAAO,KAAK,QAAQ,QAAQ,cAAc,EAAE,OAAO,CAAC;CACtD;;;;;;;CAQA,AAAO,MAAM,QAAe,cAAuB;EACjD,OAAO,KAAK,GAAG,QAAQ,YAAY;CACrC;;;;;;;CAQA,AAAO,WAAW,QAAe,cAAuB;EACtD,OAAO,KAAK,QAAQ,mBAAmB,cAAc,EAAE,eAAe,OAAO,CAAC;CAChF;;;;;;;;CASA,AAAO,QAAQ,QAAe,cAAuB;EACnD,OAAO,KAAK,QAAQ,sBAAsB,cAAc,EAAE,kBAAkB,OAAO,CAAC;CACtF;;;;;;;CAQA,AAAO,MAAM,QAAe,cAAuB;EACjD,OAAO,KAAK,QAAQ,QAAQ,YAAY;CAC1C;AACF"}
|