@warlock.js/notifications 5.29.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 +6 -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 +7 -7
- package/package.json +9 -8
- package/skills/configure-notifications/SKILL.md +1 -1
- package/skills/notifications-basics/SKILL.md +1 -1
- package/skills/queue-notifications/SKILL.md +1 -1
- package/skills/use-in-app/SKILL.md +3 -3
- package/skills/write-notification-migration/SKILL.md +1 -1
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean-validator.mjs","names":[],"sources":["../../../../../../../../../../../packages/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,OA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BAAwB,cAAc,EAAE,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computed-validator.mjs","names":[],"sources":["../../../../../../../../../../../packages/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,8 +1,8 @@
|
|
|
1
|
-
import { __toESM } from "
|
|
1
|
+
import { __toESM } from "../../../../_virtual/_rolldown/runtime.mjs";
|
|
2
2
|
import { applyNullable, getRuleOptions } from "../standard-schema/json-schema.mjs";
|
|
3
3
|
import { isDateValue } from "../helpers/date-helpers.mjs";
|
|
4
4
|
import { BaseValidator } from "./base-validator.mjs";
|
|
5
|
-
import { require_dayjs_min } from "
|
|
5
|
+
import { require_dayjs_min } from "../../../../node_modules/.pnpm/dayjs@1.11.23/node_modules/dayjs/dayjs.min.mjs";
|
|
6
6
|
import { addDaysMutator, addHoursMutator, addMonthsMutator, addYearsMutator, dateMutator, toEndOfDayMutator, toEndOfMonthMutator, toEndOfYearMutator, toStartOfDayMutator, toStartOfMonthMutator, toStartOfYearMutator, toUTCMutator } from "../mutators/date-mutators.mjs";
|
|
7
7
|
import "../mutators/index.mjs";
|
|
8
8
|
import { ageRule, beforeHourRule, beforeMinuteRule, beforeTodayRule, betweenHoursRule, betweenMinutesRule, dateRule, fromHourRule, fromMinuteRule, fromTodayRule, maxAgeRule, maxDateRule, minAgeRule, minDateRule, weekDayRule } from "../rules/date/date.mjs";
|
|
@@ -14,7 +14,7 @@ import { withinDaysRule, withinFutureDaysRule, withinPastDaysRule } from "../rul
|
|
|
14
14
|
import { betweenAgeRule, birthdayRule, leapYearRule } from "../rules/date/date-special-rules.mjs";
|
|
15
15
|
import "../rules/index.mjs";
|
|
16
16
|
|
|
17
|
-
//#region
|
|
17
|
+
//#region ../../packages/seal/src/validators/date-validator.ts
|
|
18
18
|
var import_dayjs_min = /* @__PURE__ */ __toESM(require_dayjs_min(), 1);
|
|
19
19
|
/**
|
|
20
20
|
* Date validator class
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-validator.mjs","names":[],"sources":["../../../../../../../../../../../packages/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,IAAa,gBAAb,cAAmC,cAAc;CAC/C,AAAO,YAAY,cAAuB;EACxC,MAAM;EACN,KAAK,iBAAiB;EACtB,KAAK,kBAAkB,WAAW;EAClC,KAAK,eAAe,UAAU,YAAY;CAC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,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,9 +1,9 @@
|
|
|
1
1
|
import { applyNullable, wrapNullableStrict } from "../standard-schema/json-schema.mjs";
|
|
2
|
-
import { isPlainObject } from "
|
|
2
|
+
import { isPlainObject } from "../../../../node_modules/.pnpm/@mongez_supportive-is@3.0.0/node_modules/@mongez/supportive-is/esm/index.mjs";
|
|
3
3
|
import { BaseValidator } from "./base-validator.mjs";
|
|
4
4
|
import { LiteralValidator } from "./literal-validator.mjs";
|
|
5
5
|
|
|
6
|
-
//#region
|
|
6
|
+
//#region ../../packages/seal/src/validators/discriminated-union-validator.ts
|
|
7
7
|
/** Whether a value read from the payload can be a discriminator key. */
|
|
8
8
|
function isDiscriminatorValue(value) {
|
|
9
9
|
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
@@ -77,6 +77,11 @@ var DiscriminatedUnionValidator = class DiscriminatedUnionValidator extends Base
|
|
|
77
77
|
errors: [],
|
|
78
78
|
data: null
|
|
79
79
|
};
|
|
80
|
+
if (data == null) {
|
|
81
|
+
const fallback = this.getDefaultValue();
|
|
82
|
+
if (fallback == null) return super.validate(void 0, context);
|
|
83
|
+
data = fallback;
|
|
84
|
+
}
|
|
80
85
|
if (!isPlainObject(data)) return {
|
|
81
86
|
isValid: false,
|
|
82
87
|
errors: [{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discriminated-union-validator.mjs","names":[],"sources":["../../../../../../../../../../../packages/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 { Schema, SchemaContext, ValidationResult } from \"../types\";\nimport type { InferInputObjectShape, InferOutputObjectShape } from \"../types/inference-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/** The union of every branch's input shape (distributes over the branches). */\ntype BranchInput<B> =\n B extends ObjectValidator<infer S extends Schema> ? InferInputObjectShape<S> : never;\n\n/** The union of every branch's output shape (distributes over the branches). */\ntype BranchOutput<B> =\n B extends ObjectValidator<infer S extends Schema> ? InferOutputObjectShape<S> : never;\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<BranchInput<Branches[number]>, BranchOutput<Branches[number]>> {\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 // `null` on a non-nullable union is absent, as it is for every other\n // validator: `.optional()` drops it and `.default(...)` replaces it.\n if (data == null) {\n const fallback = this.getDefaultValue();\n\n // Absent with no default: required/optional is the base pipeline's\n // question (required error, or a valid absent field under `.optional()`).\n if (fallback == null) {\n return super.validate(undefined, context);\n }\n\n data = fallback;\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":";;;;;;;AAqBA,SAAS,qBAAqB,OAA6C;CACzE,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU;AACpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAa,8BAAb,MAAa,oCAGH,cAA6E;CAK5E;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,EAC7E;IAEF,IAAI,IAAI,OAAO,MAAM;GACvB;EACF;EAEA,OAAO;CACT;CAEA,AAAgB,YAAY,OAAqB;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vB,EAAE;EAEzC,IAAI,KAAK,YAAY;GACnB,IAAI,WAAW,iBACb,OAAO,mBAAmB,MAAM;GAElC,cAAc,QAAQ,MAAM;EAC9B;EAEA,OAAO;CACT;AACF"}
|
|
@@ -2,7 +2,7 @@ import { floatRule } from "../rules/common/type-rules.mjs";
|
|
|
2
2
|
import "../rules/index.mjs";
|
|
3
3
|
import { NumberValidator } from "./number-validator.mjs";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../packages/seal/src/validators/float-validator.ts
|
|
6
6
|
/**
|
|
7
7
|
* Float validator class
|
|
8
8
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"float-validator.mjs","names":[],"sources":["../../../../../../../../../../../packages/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,7 +1,7 @@
|
|
|
1
1
|
import { BaseValidator } from "./base-validator.mjs";
|
|
2
2
|
import { instanceofRule } from "../rules/common/instanceof.mjs";
|
|
3
3
|
|
|
4
|
-
//#region
|
|
4
|
+
//#region ../../packages/seal/src/validators/instanceof-validator.ts
|
|
5
5
|
/**
|
|
6
6
|
* InstanceOf validator class
|
|
7
7
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instanceof-validator.mjs","names":[],"sources":["../../../../../../../../../../../packages/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"}
|
|
@@ -2,7 +2,7 @@ import { intRule } from "../rules/common/type-rules.mjs";
|
|
|
2
2
|
import "../rules/index.mjs";
|
|
3
3
|
import { NumberValidator } from "./number-validator.mjs";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../packages/seal/src/validators/int-validator.ts
|
|
6
6
|
/**
|
|
7
7
|
* Integer validator class
|
|
8
8
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"int-validator.mjs","names":[],"sources":["../../../../../../../../../../../packages/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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-validator.mjs","names":[],"sources":["../../../../../../../../../../../packages/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,8 +1,9 @@
|
|
|
1
1
|
import { applyNullable } from "../standard-schema/json-schema.mjs";
|
|
2
|
+
import { presentRule } from "../rules/core/required.mjs";
|
|
2
3
|
import { BaseValidator } from "./base-validator.mjs";
|
|
3
4
|
import { literalRule } from "../rules/common/literal.mjs";
|
|
4
5
|
|
|
5
|
-
//#region
|
|
6
|
+
//#region ../../packages/seal/src/validators/literal-validator.ts
|
|
6
7
|
/**
|
|
7
8
|
* Literal validator class
|
|
8
9
|
*
|
|
@@ -21,9 +22,11 @@ var LiteralValidator = class extends BaseValidator {
|
|
|
21
22
|
values;
|
|
22
23
|
constructor(values, errorMessage) {
|
|
23
24
|
super();
|
|
24
|
-
this.blankIsMissing = true;
|
|
25
25
|
this.values = values;
|
|
26
26
|
this.addMutableRule(literalRule, errorMessage, { values });
|
|
27
|
+
const acceptsBlank = values.some((value) => typeof value === "string" && value.trim() === "");
|
|
28
|
+
this.blankIsMissing = !acceptsBlank;
|
|
29
|
+
if (acceptsBlank) this.requiredRule = this.createRule(presentRule);
|
|
27
30
|
}
|
|
28
31
|
/**
|
|
29
32
|
* Check if value is one of the configured literals
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"literal-validator.mjs","names":[],"sources":["../../../../../../../../../../../packages/seal/src/validators/literal-validator.ts"],"sourcesContent":["import { literalRule } from \"../rules/common/literal\";\nimport { presentRule } from \"../rules/core/required\";\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.values = values;\n this.addMutableRule(literalRule, errorMessage, { values });\n\n // A blank form value counts as missing for literal/enum sets (5.25), so an\n // unselected `<select>` reads as absent. That cannot apply when the author\n // listed a blank string as an accepted value: there `\"\"` is a value, not an\n // absence, and `alt=\"\"` and no `alt` at all mean different things.\n const acceptsBlank = values.some((value) => typeof value === \"string\" && value.trim() === \"\");\n\n this.blankIsMissing = !acceptsBlank;\n\n // Every validator is required by default, and `required` rejects anything\n // `isEmptyValue` calls empty, including `\"\"`. When the set accepts a blank\n // value, swap `required` for `present`: the key must still exist, and\n // judging the value is the literal rule's job.\n if (acceptsBlank) {\n this.requiredRule = this.createRule(presentRule);\n }\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":";;;;;;;;;;;;;;;;;;;;AAoBA,IAAa,mBAAb,cAEU,cAAc;CACtB,AAAO;CAEP,AAAO,YAAY,QAAW,cAAuB;EACnD,MAAM;EACN,KAAK,SAAS;EACd,KAAK,eAAe,aAAa,cAAc,EAAE,OAAO,CAAC;EAMzD,MAAM,eAAe,OAAO,MAAM,UAAU,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,EAAE;EAE5F,KAAK,iBAAiB,CAAC;EAMvB,IAAI,cACF,KAAK,eAAe,KAAK,WAAW,WAAW;CAEnD;;;;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managed-validator.mjs","names":[],"sources":["../../../../../../../../../../../packages/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"}
|
|
@@ -4,7 +4,7 @@ import { whenRule } from "../../rules/core/when.mjs";
|
|
|
4
4
|
import { equalsFieldRule, notEqualsFieldRule } from "../../rules/common/equals-field-rules.mjs";
|
|
5
5
|
import "../../rules/index.mjs";
|
|
6
6
|
|
|
7
|
-
//#region
|
|
7
|
+
//#region ../../packages/seal/src/validators/methods/equality-conditional-methods.ts
|
|
8
8
|
/**
|
|
9
9
|
* Value must be equal to the given value
|
|
10
10
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"equality-conditional-methods.mjs","names":[],"sources":["../../../../../../../../../../../../packages/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"}
|
|
@@ -2,7 +2,7 @@ import { BaseValidator } from "../base-validator.mjs";
|
|
|
2
2
|
import { forbiddenRule } from "../../rules/core/forbidden.mjs";
|
|
3
3
|
import { forbiddenIfEmptyRule, forbiddenIfInRule, forbiddenIfNotEmptyRule, forbiddenIfNotInRule, forbiddenIfNotRule, forbiddenIfRule } from "../../rules/conditional/forbidden-if-rules.mjs";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../packages/seal/src/validators/methods/forbidden-methods.ts
|
|
6
6
|
/**
|
|
7
7
|
* Value is forbidden to be present
|
|
8
8
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forbidden-methods.mjs","names":[],"sources":["../../../../../../../../../../../../packages/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"}
|
|
@@ -4,7 +4,7 @@ import { presentUnlessRule } from "../../rules/conditional/present-unless-rules.
|
|
|
4
4
|
import { presentWithAllRule, presentWithAnyRule, presentWithRule } from "../../rules/conditional/present-with-rules.mjs";
|
|
5
5
|
import { presentWithoutAllRule, presentWithoutAnyRule, presentWithoutRule } from "../../rules/conditional/present-without-rules.mjs";
|
|
6
6
|
|
|
7
|
-
//#region
|
|
7
|
+
//#region ../../packages/seal/src/validators/methods/present-methods.ts
|
|
8
8
|
/**
|
|
9
9
|
* Field must be present if another field exists
|
|
10
10
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"present-methods.mjs","names":[],"sources":["../../../../../../../../../../../../packages/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,oBAA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AQ,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"}
|
|
@@ -6,7 +6,7 @@ import { requiredWhenRule } from "../../rules/conditional/required-when-rule.mjs
|
|
|
6
6
|
import { requiredWithAllRule, requiredWithAnyRule, requiredWithRule } from "../../rules/conditional/required-with-rules.mjs";
|
|
7
7
|
import { requiredWithoutAllRule, requiredWithoutAnyRule, requiredWithoutRule } from "../../rules/conditional/required-without-rules.mjs";
|
|
8
8
|
|
|
9
|
-
//#region
|
|
9
|
+
//#region ../../packages/seal/src/validators/methods/required-methods.ts
|
|
10
10
|
/**
|
|
11
11
|
* This value must be present and has a value
|
|
12
12
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"required-methods.mjs","names":[],"sources":["../../../../../../../../../../../../packages/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,SAAS,eAAe;CACxB,OAAO;AACT;;;;AAKA,cAAc,UAAU,UAAU,WAGhC;CAEA,OADiB,KAAK,SAAS,CAAC,CAAC,SACnB;AAChB;;;;AAOA,cAAc,UAAU,eAAe,SAAU,OAAe,cAAuB;CACrF,OAAO,KAAK,gBAAgB,kBAAkB,cAAc;EAAE;EAAO,OAAO;CAAS,CAAC;AACxF;;;;AAKA,cAAc,UAAU,sBAAsB,SAAU,OAAe,cAAuB;CAC5F,OAAO,KAAK,gBAAgB,kBAAkB,cAAc;EAAE;EAAO,OAAO;CAAU,CAAC;AACzF;;;;AAKA,cAAc,UAAU,kBAAkB,SAAU,OAAe,cAAuB;CACxF,OAAO,KAAK,gBAAgB,qBAAqB,cAAc;EAAE;EAAO,OAAO;CAAS,CAAC;AAC3F;;;;AAKA,cAAc,UAAU,yBAAyB,SAAU,OAAe,cAAuB;CAC/F,OAAO,KAAK,gBA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OAAO,KAAK,gBAAgB,kBAAkB,cAAc,EAAE,SAAS,CAAC;AAC1E"}
|
|
@@ -7,7 +7,7 @@ import { numberRule } from "../rules/common/type-rules.mjs";
|
|
|
7
7
|
import "../rules/index.mjs";
|
|
8
8
|
import { PrimitiveValidator } from "./primitive-validator.mjs";
|
|
9
9
|
|
|
10
|
-
//#region
|
|
10
|
+
//#region ../../packages/seal/src/validators/number-validator.ts
|
|
11
11
|
/**
|
|
12
12
|
* Number validator class - base for Int and Float validators
|
|
13
13
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-validator.mjs","names":[],"sources":["../../../../../../../../../../../packages/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,OAAwB,cAAuB;EAChE,OAAO,KAAK,QAAQ,iBAAiB,cAAc;GACjD;GACA,OAAO;EACT,CAAC;CACH;;;;;;;CAQA,AAAO,SAAS,OAAwB,cAAuB;EAC7D,OAAO,KAAK,QAAQ,cAAc,cAAc;GAC9C;GACA,OAAO;EACT,CAAC;CACH;;;;;CAMA,AAAO,GAAG,OAAwB,cAAuB;EACvD,OAAO,KAAK,YAAY,OAAO,YAAY;CAC7C;;;;;CAMA,AA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,QAAQ;EAI3B,MAAM,cAAc,eAAe,KAAK,OAAO,gBAAgB;EAC/D,IAAI,aAAa;GACf,IAAI,OAAO,YAAY,QAAQ,UAAU,OAAO,UAAU,YAAY;GACtE,IAAI,OAAO,YAAY,QAAQ,UAAU,OAAO,UAAU,YAAY;EACxE;EAGA,MAAM,SAAS,eAAe,KAAK,OAAO,aAAa;EACvD,IAAI,QAAQ,UAAU,UAAa,OAAO,OAAO,UAAU,UACzD,IAAI,WAAW,YAAY;GACzB,OAAO,UAAU,OAAO;GACxB,OAAO,mBAAmB;EAC5B,OACE,OAAO,mBAAmB,OAAO;EAKrC,MAAM,SAAS,eAAe,KAAK,OAAO,UAAU;EACpD,IAAI,QAAQ,UAAU,UAAa,OAAO,OAAO,UAAU,UACzD,IAAI,WAAW,YAAY;GACzB,OAAO,UAAU,OAAO;GACxB,OAAO,mBAAmB;EAC5B,OACE,OAAO,mBAAmB,OAAO;EAKrC,MAAM,aAAa,eAAe,KAAK,OAAO,QAAQ;EACtD,IAAI,YAAY,UAAU,UAAa,OAAO,WAAW,UAAU,UACjE,OAAO,aAAa,WAAW;EAIjC,MAAM,SAAS,eAAe,KAAK,OAAO,IAAI;EAC9C,IAAI,QAAQ,UAAU,MAAM,QAAQ,OAAO,MAAM,GAC/C,OAAO,OAAO,OAAO;EAGvB,IAAI,KAAK,YAAY,cAAc,QAAQ,MAAM;EAEjD,OAAO;CACT;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { isNumeric } from "
|
|
1
|
+
import { isNumeric } from "../../../../node_modules/.pnpm/@mongez_supportive-is@3.0.0/node_modules/@mongez/supportive-is/esm/index.mjs";
|
|
2
2
|
import { numericMutator } from "../mutators/number-mutators.mjs";
|
|
3
3
|
import { NumberValidator } from "./number-validator.mjs";
|
|
4
4
|
|
|
5
|
-
//#region
|
|
5
|
+
//#region ../../packages/seal/src/validators/numeric-validator.ts
|
|
6
6
|
/**
|
|
7
7
|
* Numeric validator class - base for Int and Float validators either as number or string
|
|
8
8
|
*/
|