@warlock.js/notifications 5.31.0 → 5.33.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 +20 -0
- package/cjs/index.cjs +2 -2
- package/cjs/index.cjs.map +1 -1
- package/esm/channels/database-channel.d.mts +2 -3
- package/esm/channels/database-channel.d.mts.map +1 -1
- package/esm/channels/index.d.mts +2 -1
- package/esm/channels/index.mjs +1 -1
- package/esm/channels/mail-channel.d.mts +6 -4
- package/esm/channels/mail-channel.d.mts.map +1 -1
- package/esm/config.d.mts +13 -9
- package/esm/config.d.mts.map +1 -1
- package/esm/contracts/channel.contract.d.mts +1 -3
- package/esm/contracts/channel.contract.d.mts.map +1 -1
- package/esm/contracts/index.d.mts +2 -1
- package/esm/contracts/notification.contract.d.mts +1 -3
- package/esm/contracts/notification.contract.d.mts.map +1 -1
- package/esm/contracts/preference-provider.contract.d.mts +1 -3
- package/esm/contracts/preference-provider.contract.d.mts.map +1 -1
- package/esm/contracts/queue-dispatcher.contract.d.mts +1 -3
- package/esm/contracts/queue-dispatcher.contract.d.mts.map +1 -1
- package/esm/contracts/rate-limiter.contract.d.mts +1 -3
- package/esm/contracts/rate-limiter.contract.d.mts.map +1 -1
- package/esm/dispatch/define-channel.d.mts +2 -2
- package/esm/dispatch/define-channel.d.mts.map +1 -1
- package/esm/dispatch/define-notification.d.mts +5 -6
- package/esm/dispatch/define-notification.d.mts.map +1 -1
- package/esm/dispatch/index.d.mts +2 -1
- package/esm/dispatch/index.mjs +1 -1
- package/esm/dispatch/notifications-event-bus.d.mts +2 -3
- package/esm/dispatch/notifications-event-bus.d.mts.map +1 -1
- package/esm/dispatch/notify.d.mts +3 -5
- package/esm/dispatch/notify.d.mts.map +1 -1
- package/esm/errors.d.mts +5 -6
- package/esm/errors.d.mts.map +1 -1
- package/esm/in-app/base-notifications-repository.d.mts +6 -6
- 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 +11 -8
- package/esm/in-app/column-map.d.mts.map +1 -1
- package/esm/in-app/database-notification.d.mts +2 -3
- package/esm/in-app/database-notification.d.mts.map +1 -1
- package/esm/in-app/in-app.d.mts +6 -5
- package/esm/in-app/in-app.d.mts.map +1 -1
- package/esm/in-app/index.d.mts +2 -1
- package/esm/in-app/index.mjs +1 -1
- package/esm/index.d.mts +6 -0
- package/esm/migration/index.d.mts +2 -1
- package/esm/migration/index.mjs +1 -1
- package/esm/migration/notification-columns.d.mts +6 -7
- package/esm/migration/notification-columns.d.mts.map +1 -1
- package/esm/queue/bullmq-queue.d.mts +9 -7
- package/esm/queue/bullmq-queue.d.mts.map +1 -1
- package/esm/queue/herald-queue.d.mts +6 -4
- package/esm/queue/herald-queue.d.mts.map +1 -1
- package/esm/queue/index.d.mts +2 -1
- package/esm/queue/index.mjs +1 -1
- package/esm/queue/load-herald.d.mts +1 -2
- package/esm/queue/load-herald.d.mts.map +1 -1
- package/esm/queue/load-herald.mjs +1 -1
- package/esm/queue/load-queue.d.mts +2 -3
- package/esm/queue/load-queue.d.mts.map +1 -1
- package/esm/queue/notifications-worker.d.mts +5 -4
- package/esm/queue/notifications-worker.d.mts.map +1 -1
- package/esm/queue/queue-package-not-installed.error.d.mts +1 -2
- package/esm/queue/queue-package-not-installed.error.d.mts.map +1 -1
- package/esm/types.d.mts +22 -18
- package/esm/types.d.mts.map +1 -1
- package/package.json +10 -9
- package/cjs/channel_api-C5ZZDkgQ.cjs +0 -7463
- package/cjs/channel_api-C5ZZDkgQ.cjs.map +0 -1
- package/cjs/chunk-fl3r8ClO.cjs +0 -41
- package/cjs/rabbitmq-driver-CkPaCswV.cjs +0 -3
- package/cjs/src-CcbF8Hr1.cjs +0 -11276
- package/cjs/src-CcbF8Hr1.cjs.map +0 -1
- package/esm/_virtual/_rolldown/runtime.mjs +0 -32
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/_internal.mjs +0 -6
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/_internal.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/bool.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/color.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/date.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/float.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/id.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/int.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/nanoid.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/pick.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/random.mjs +0 -16
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/sample.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/string.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/token.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/uuid.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/Random/weighted.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/async/retry.mjs +0 -3
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/index.mjs +0 -24
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/mixed/clone/clone.mjs +0 -82
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/mixed/clone/clone.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/number/round.mjs +0 -17
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/number/round.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/except.mjs +0 -13
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/except.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/get.mjs +0 -18
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/get.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/omit.mjs +0 -17
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/omit.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/unset.mjs +0 -30
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/unset.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/capitalize.mjs +0 -19
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/capitalize.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ltrim.mjs +0 -18
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ltrim.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/readMoreChars.mjs +0 -14
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/readMoreChars.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/rtrim.mjs +0 -18
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/rtrim.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toCamelCase.mjs +0 -22
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toCamelCase.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toKebabCase.mjs +0 -17
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toKebabCase.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toSnakeCase.mjs +0 -21
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toSnakeCase.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toStudlyCase.mjs +0 -21
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/toStudlyCase.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/trim.mjs +0 -20
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/trim.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ucfirst.mjs +0 -15
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/ucfirst.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/words.mjs +0 -25
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/string/words.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/escapeRegex.mjs +0 -11
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/escapeRegex.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/lazy.mjs +0 -100
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/lazy.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/tap.mjs +0 -27
- package/esm/node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/utils/tap.mjs.map +0 -1
- package/esm/node_modules/.pnpm/@mongez_supportive-is@3.0.0/node_modules/@mongez/supportive-is/esm/index.mjs +0 -358
- package/esm/node_modules/.pnpm/@mongez_supportive-is@3.0.0/node_modules/@mongez/supportive-is/esm/index.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/channel_api.mjs +0 -28
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/channel_api.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/api_args.mjs +0 -241
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/api_args.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/bitset.mjs +0 -130
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/bitset.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/channel.mjs +0 -302
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/channel.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/channel_model.mjs +0 -206
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/channel_model.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/codec.mjs +0 -273
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/codec.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/connect.mjs +0 -143
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/connect.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/connection.mjs +0 -416
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/connection.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/credentials.mjs +0 -50
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/credentials.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/defs.mjs +0 -4600
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/defs.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/error.mjs +0 -29
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/error.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/format.mjs +0 -28
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/format.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/frame.mjs +0 -130
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/frame.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/heartbeat.mjs +0 -40
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/heartbeat.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/mux.mjs +0 -86
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/lib/mux.mjs.map +0 -1
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/package.mjs +0 -41
- package/esm/node_modules/.pnpm/amqplib@0.10.9/node_modules/amqplib/package.mjs.map +0 -1
- package/esm/node_modules/.pnpm/buffer-more-ints@1.0.0/node_modules/buffer-more-ints/buffer-more-ints.mjs +0 -360
- package/esm/node_modules/.pnpm/buffer-more-ints@1.0.0/node_modules/buffer-more-ints/buffer-more-ints.mjs.map +0 -1
- package/esm/node_modules/.pnpm/dayjs@1.11.23/node_modules/dayjs/dayjs.min.mjs +0 -305
- package/esm/node_modules/.pnpm/dayjs@1.11.23/node_modules/dayjs/dayjs.min.mjs.map +0 -1
- package/esm/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.mjs +0 -80
- package/esm/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.mjs.map +0 -1
- package/esm/node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.mjs +0 -35
- package/esm/node_modules/.pnpm/requires-port@1.0.0/node_modules/requires-port/index.mjs.map +0 -1
- package/esm/node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.mjs +0 -388
- package/esm/node_modules/.pnpm/url-parse@1.5.10/node_modules/url-parse/index.mjs.map +0 -1
- package/esm/packages/herald/src/communicators/broker-registry.mjs +0 -204
- package/esm/packages/herald/src/communicators/broker-registry.mjs.map +0 -1
- package/esm/packages/herald/src/communicators/broker.mjs +0 -110
- package/esm/packages/herald/src/communicators/broker.mjs.map +0 -1
- package/esm/packages/herald/src/communicators/index.mjs +0 -4
- package/esm/packages/herald/src/decorators/consumable.mjs +0 -36
- package/esm/packages/herald/src/decorators/consumable.mjs.map +0 -1
- package/esm/packages/herald/src/decorators/index.mjs +0 -3
- package/esm/packages/herald/src/drivers/index.mjs +0 -5
- package/esm/packages/herald/src/drivers/rabbitmq/index.mjs +0 -4
- package/esm/packages/herald/src/drivers/rabbitmq/rabbitmq-channel.mjs +0 -403
- package/esm/packages/herald/src/drivers/rabbitmq/rabbitmq-channel.mjs.map +0 -1
- package/esm/packages/herald/src/drivers/rabbitmq/rabbitmq-driver.mjs +0 -303
- package/esm/packages/herald/src/drivers/rabbitmq/rabbitmq-driver.mjs.map +0 -1
- package/esm/packages/herald/src/index.mjs +0 -16
- package/esm/packages/herald/src/message-managers/event-consumer.mjs +0 -76
- package/esm/packages/herald/src/message-managers/event-consumer.mjs.map +0 -1
- package/esm/packages/herald/src/message-managers/event-message.mjs +0 -85
- package/esm/packages/herald/src/message-managers/event-message.mjs.map +0 -1
- package/esm/packages/herald/src/message-managers/index.mjs +0 -4
- package/esm/packages/herald/src/message-managers/prepare-consumer-subscription.mjs +0 -42
- package/esm/packages/herald/src/message-managers/prepare-consumer-subscription.mjs.map +0 -1
- package/esm/packages/herald/src/use-case-broadcast.mjs +0 -30
- package/esm/packages/herald/src/use-case-broadcast.mjs.map +0 -1
- package/esm/packages/herald/src/utils/connect-to-broker.mjs +0 -168
- package/esm/packages/herald/src/utils/connect-to-broker.mjs.map +0 -1
- package/esm/packages/herald/src/utils/index.mjs +0 -3
- package/esm/packages/seal/src/config.mjs +0 -15
- package/esm/packages/seal/src/config.mjs.map +0 -1
- package/esm/packages/seal/src/factory/index.mjs +0 -4
- package/esm/packages/seal/src/factory/validate.mjs +0 -42
- package/esm/packages/seal/src/factory/validate.mjs.map +0 -1
- package/esm/packages/seal/src/factory/validators.mjs +0 -139
- package/esm/packages/seal/src/factory/validators.mjs.map +0 -1
- package/esm/packages/seal/src/helpers/date-helpers.mjs +0 -24
- package/esm/packages/seal/src/helpers/date-helpers.mjs.map +0 -1
- package/esm/packages/seal/src/helpers/get-field-value.mjs +0 -46
- package/esm/packages/seal/src/helpers/get-field-value.mjs.map +0 -1
- package/esm/packages/seal/src/helpers/index.mjs +0 -6
- package/esm/packages/seal/src/helpers/is-empty-value.mjs +0 -10
- package/esm/packages/seal/src/helpers/is-empty-value.mjs.map +0 -1
- package/esm/packages/seal/src/helpers/path-helpers.mjs +0 -12
- package/esm/packages/seal/src/helpers/path-helpers.mjs.map +0 -1
- package/esm/packages/seal/src/helpers/validation-helpers.mjs +0 -78
- package/esm/packages/seal/src/helpers/validation-helpers.mjs.map +0 -1
- package/esm/packages/seal/src/index.mjs +0 -88
- package/esm/packages/seal/src/mutators/array-mutators.mjs +0 -32
- package/esm/packages/seal/src/mutators/array-mutators.mjs.map +0 -1
- package/esm/packages/seal/src/mutators/boolean-mutators.mjs +0 -40
- package/esm/packages/seal/src/mutators/boolean-mutators.mjs.map +0 -1
- package/esm/packages/seal/src/mutators/date-mutators.mjs +0 -94
- package/esm/packages/seal/src/mutators/date-mutators.mjs.map +0 -1
- package/esm/packages/seal/src/mutators/index.mjs +0 -9
- package/esm/packages/seal/src/mutators/number-mutators.mjs +0 -52
- package/esm/packages/seal/src/mutators/number-mutators.mjs.map +0 -1
- package/esm/packages/seal/src/mutators/object-mutators.mjs +0 -30
- package/esm/packages/seal/src/mutators/object-mutators.mjs.map +0 -1
- package/esm/packages/seal/src/mutators/scalar-mutators.mjs +0 -9
- package/esm/packages/seal/src/mutators/scalar-mutators.mjs.map +0 -1
- package/esm/packages/seal/src/mutators/string-mutators.mjs +0 -186
- package/esm/packages/seal/src/mutators/string-mutators.mjs.map +0 -1
- package/esm/packages/seal/src/object.mjs +0 -13
- package/esm/packages/seal/src/object.mjs.map +0 -1
- package/esm/packages/seal/src/rules/array/array-rules.mjs +0 -41
- package/esm/packages/seal/src/rules/array/array-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/array/index.mjs +0 -3
- package/esm/packages/seal/src/rules/color/color-rules.mjs +0 -104
- package/esm/packages/seal/src/rules/color/color-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/color/index.mjs +0 -3
- package/esm/packages/seal/src/rules/common/enum.mjs +0 -77
- package/esm/packages/seal/src/rules/common/enum.mjs.map +0 -1
- package/esm/packages/seal/src/rules/common/equals-field-rules.mjs +0 -42
- package/esm/packages/seal/src/rules/common/equals-field-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/common/index.mjs +0 -8
- package/esm/packages/seal/src/rules/common/instanceof.mjs +0 -23
- package/esm/packages/seal/src/rules/common/instanceof.mjs.map +0 -1
- package/esm/packages/seal/src/rules/common/literal.mjs +0 -31
- package/esm/packages/seal/src/rules/common/literal.mjs.map +0 -1
- package/esm/packages/seal/src/rules/common/type-rules.mjs +0 -97
- package/esm/packages/seal/src/rules/common/type-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/common/unknown-key.mjs +0 -25
- package/esm/packages/seal/src/rules/common/unknown-key.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/forbidden-if-rules.mjs +0 -116
- package/esm/packages/seal/src/rules/conditional/forbidden-if-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/index.mjs +0 -12
- package/esm/packages/seal/src/rules/conditional/present-if-rules.mjs +0 -97
- package/esm/packages/seal/src/rules/conditional/present-if-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/present-unless-rules.mjs +0 -30
- package/esm/packages/seal/src/rules/conditional/present-unless-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/present-with-rules.mjs +0 -76
- package/esm/packages/seal/src/rules/conditional/present-with-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/present-without-rules.mjs +0 -76
- package/esm/packages/seal/src/rules/conditional/present-without-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/required-if-rules.mjs +0 -204
- package/esm/packages/seal/src/rules/conditional/required-if-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/required-unless-rules.mjs +0 -31
- package/esm/packages/seal/src/rules/conditional/required-unless-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/required-when-rule.mjs +0 -32
- package/esm/packages/seal/src/rules/conditional/required-when-rule.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/required-with-rules.mjs +0 -67
- package/esm/packages/seal/src/rules/conditional/required-with-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/conditional/required-without-rules.mjs +0 -67
- package/esm/packages/seal/src/rules/conditional/required-without-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/core/equal.mjs +0 -22
- package/esm/packages/seal/src/rules/core/equal.mjs.map +0 -1
- package/esm/packages/seal/src/rules/core/forbidden.mjs +0 -20
- package/esm/packages/seal/src/rules/core/forbidden.mjs.map +0 -1
- package/esm/packages/seal/src/rules/core/index.mjs +0 -7
- package/esm/packages/seal/src/rules/core/required.mjs +0 -36
- package/esm/packages/seal/src/rules/core/required.mjs.map +0 -1
- package/esm/packages/seal/src/rules/core/union.mjs +0 -78
- package/esm/packages/seal/src/rules/core/union.mjs.map +0 -1
- package/esm/packages/seal/src/rules/core/when.mjs +0 -37
- package/esm/packages/seal/src/rules/core/when.mjs.map +0 -1
- package/esm/packages/seal/src/rules/date/date-comparison-rules.mjs +0 -78
- package/esm/packages/seal/src/rules/date/date-comparison-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/date/date-day-rules.mjs +0 -49
- package/esm/packages/seal/src/rules/date/date-day-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/date/date-field-comparison-rules.mjs +0 -82
- package/esm/packages/seal/src/rules/date/date-field-comparison-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/date/date-period-rules.mjs +0 -401
- package/esm/packages/seal/src/rules/date/date-period-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/date/date-relative-rules.mjs +0 -55
- package/esm/packages/seal/src/rules/date/date-relative-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/date/date-special-rules.mjs +0 -58
- package/esm/packages/seal/src/rules/date/date-special-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/date/date.mjs +0 -235
- package/esm/packages/seal/src/rules/date/date.mjs.map +0 -1
- package/esm/packages/seal/src/rules/date/index.mjs +0 -9
- package/esm/packages/seal/src/rules/file/dimensions.mjs +0 -3
- package/esm/packages/seal/src/rules/file/file-size.mjs +0 -3
- package/esm/packages/seal/src/rules/file/index.mjs +0 -4
- package/esm/packages/seal/src/rules/index.mjs +0 -54
- package/esm/packages/seal/src/rules/length/index.mjs +0 -3
- package/esm/packages/seal/src/rules/length/length-rules.mjs +0 -98
- package/esm/packages/seal/src/rules/length/length-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/number/index.mjs +0 -3
- package/esm/packages/seal/src/rules/number/number-rules.mjs +0 -197
- package/esm/packages/seal/src/rules/number/number-rules.mjs.map +0 -1
- package/esm/packages/seal/src/rules/scalar/accepted-rule.mjs +0 -123
- package/esm/packages/seal/src/rules/scalar/accepted-rule.mjs.map +0 -1
- package/esm/packages/seal/src/rules/scalar/declined-rule.mjs +0 -123
- package/esm/packages/seal/src/rules/scalar/declined-rule.mjs.map +0 -1
- package/esm/packages/seal/src/rules/scalar/index.mjs +0 -4
- package/esm/packages/seal/src/rules/string/alpha.mjs +0 -41
- package/esm/packages/seal/src/rules/string/alpha.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/credit-card.mjs +0 -32
- package/esm/packages/seal/src/rules/string/credit-card.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/email.mjs +0 -20
- package/esm/packages/seal/src/rules/string/email.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/id-formats.mjs +0 -104
- package/esm/packages/seal/src/rules/string/id-formats.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/index.mjs +0 -13
- package/esm/packages/seal/src/rules/string/ip.mjs +0 -66
- package/esm/packages/seal/src/rules/string/ip.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/matches.mjs +0 -4
- package/esm/packages/seal/src/rules/string/pattern.mjs +0 -20
- package/esm/packages/seal/src/rules/string/pattern.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/string-comparison.mjs +0 -56
- package/esm/packages/seal/src/rules/string/string-comparison.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/strong-password-rule.mjs +0 -31
- package/esm/packages/seal/src/rules/string/strong-password-rule.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/url.mjs +0 -23
- package/esm/packages/seal/src/rules/string/url.mjs.map +0 -1
- package/esm/packages/seal/src/rules/string/without-whitespace.mjs +0 -19
- package/esm/packages/seal/src/rules/string/without-whitespace.mjs.map +0 -1
- package/esm/packages/seal/src/standard-schema/json-schema.mjs +0 -81
- package/esm/packages/seal/src/standard-schema/json-schema.mjs.map +0 -1
- package/esm/packages/seal/src/standard-schema/map-result.mjs +0 -26
- package/esm/packages/seal/src/standard-schema/map-result.mjs.map +0 -1
- package/esm/packages/seal/src/string.mjs +0 -13
- package/esm/packages/seal/src/string.mjs.map +0 -1
- package/esm/packages/seal/src/types/date-types.mjs +0 -17
- package/esm/packages/seal/src/types/date-types.mjs.map +0 -1
- package/esm/packages/seal/src/validators/any-validator.mjs +0 -38
- package/esm/packages/seal/src/validators/any-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/array-validator.mjs +0 -186
- package/esm/packages/seal/src/validators/array-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/base-validator.mjs +0 -750
- package/esm/packages/seal/src/validators/base-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/boolean-validator.mjs +0 -175
- package/esm/packages/seal/src/validators/boolean-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/computed-validator.mjs +0 -118
- package/esm/packages/seal/src/validators/computed-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/date-validator.mjs +0 -640
- package/esm/packages/seal/src/validators/date-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/discriminated-union-validator.mjs +0 -138
- package/esm/packages/seal/src/validators/discriminated-union-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/float-validator.mjs +0 -18
- package/esm/packages/seal/src/validators/float-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/index.mjs +0 -28
- package/esm/packages/seal/src/validators/instanceof-validator.mjs +0 -64
- package/esm/packages/seal/src/validators/instanceof-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/int-validator.mjs +0 -30
- package/esm/packages/seal/src/validators/int-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/lazy-validator.mjs +0 -87
- package/esm/packages/seal/src/validators/lazy-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/literal-validator.mjs +0 -72
- package/esm/packages/seal/src/validators/literal-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/managed-validator.mjs +0 -39
- package/esm/packages/seal/src/validators/managed-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/methods/equality-conditional-methods.mjs +0 -129
- package/esm/packages/seal/src/validators/methods/equality-conditional-methods.mjs.map +0 -1
- package/esm/packages/seal/src/validators/methods/forbidden-methods.mjs +0 -131
- package/esm/packages/seal/src/validators/methods/forbidden-methods.mjs.map +0 -1
- package/esm/packages/seal/src/validators/methods/present-methods.mjs +0 -235
- package/esm/packages/seal/src/validators/methods/present-methods.mjs.map +0 -1
- package/esm/packages/seal/src/validators/methods/required-methods.mjs +0 -347
- package/esm/packages/seal/src/validators/methods/required-methods.mjs.map +0 -1
- package/esm/packages/seal/src/validators/number-validator.mjs +0 -331
- package/esm/packages/seal/src/validators/number-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/numeric-validator.mjs +0 -27
- package/esm/packages/seal/src/validators/numeric-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/object-validator.mjs +0 -447
- package/esm/packages/seal/src/validators/object-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/primitive-validator.mjs +0 -88
- package/esm/packages/seal/src/validators/primitive-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/record-validator.mjs +0 -112
- package/esm/packages/seal/src/validators/record-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/scalar-validator.mjs +0 -173
- package/esm/packages/seal/src/validators/scalar-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/string-validator.mjs +0 -459
- package/esm/packages/seal/src/validators/string-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/tuple-validator.mjs +0 -134
- package/esm/packages/seal/src/validators/tuple-validator.mjs.map +0 -1
- package/esm/packages/seal/src/validators/union-validator.mjs +0 -68
- package/esm/packages/seal/src/validators/union-validator.mjs.map +0 -1
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
|
|
2
|
-
import "../../helpers/index.mjs";
|
|
3
|
-
|
|
4
|
-
//#region ../../packages/seal/src/rules/core/union.ts
|
|
5
|
-
const describeFailure = (index, errors) => ({
|
|
6
|
-
index,
|
|
7
|
-
errors,
|
|
8
|
-
literalMismatches: errors.filter((error) => error.type === "literal").length,
|
|
9
|
-
depth: Math.max(0, ...errors.map((error) => error.input ? error.input.split(".").length : 0))
|
|
10
|
-
});
|
|
11
|
-
/**
|
|
12
|
-
* Whether `candidate` is closer to the value than `best`:
|
|
13
|
-
*
|
|
14
|
-
* 1. Fewest mismatched literals. A literal that does not match (`kind: "owner"`
|
|
15
|
-
* given `"member"`) says the value is a different member, while any other
|
|
16
|
-
* error says it is this member with a bad field.
|
|
17
|
-
* 2. Fewest errors.
|
|
18
|
-
* 3. Deepest error: the member matched more of the value's structure.
|
|
19
|
-
* 4. Declaration order (an earlier member wins a tie).
|
|
20
|
-
*/
|
|
21
|
-
const isCloser = (candidate, best) => {
|
|
22
|
-
if (candidate.literalMismatches !== best.literalMismatches) return candidate.literalMismatches < best.literalMismatches;
|
|
23
|
-
if (candidate.errors.length !== best.errors.length) return candidate.errors.length < best.errors.length;
|
|
24
|
-
if (candidate.depth !== best.depth) return candidate.depth > best.depth;
|
|
25
|
-
return candidate.index < best.index;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Union rule - value must match at least one of the provided validators.
|
|
29
|
-
*
|
|
30
|
-
* Every member whose type matches the value is tried, in order, until one
|
|
31
|
-
* passes. When none passes, the errors of the closest failed member (see
|
|
32
|
-
* `isCloser`) are reported at their own paths with the `union` type: its
|
|
33
|
-
* first error under `firstErrorOnly` (the default), all of them otherwise.
|
|
34
|
-
* A custom union error message replaces them with a single error, as does the
|
|
35
|
-
* default message when no member matches the value's type.
|
|
36
|
-
*/
|
|
37
|
-
const unionRule = {
|
|
38
|
-
name: "union",
|
|
39
|
-
requiresValue: false,
|
|
40
|
-
defaultErrorMessage: "Value must match one of the allowed types",
|
|
41
|
-
async validate(value, context) {
|
|
42
|
-
if (value === void 0) return VALID_RULE;
|
|
43
|
-
const validators = this.context.options.validators;
|
|
44
|
-
const firstErrorOnly = context.configurations?.firstErrorOnly ?? true;
|
|
45
|
-
let closest;
|
|
46
|
-
for (const [index, validator] of validators.entries()) {
|
|
47
|
-
if (!validator.matchesType(value)) continue;
|
|
48
|
-
const result = await validator.validate(value, { ...context });
|
|
49
|
-
if (result.isValid) return {
|
|
50
|
-
isValid: true,
|
|
51
|
-
data: result.data
|
|
52
|
-
};
|
|
53
|
-
const failure = describeFailure(index, result.errors?.length ? result.errors : [{
|
|
54
|
-
type: "union",
|
|
55
|
-
error: "Validation failed",
|
|
56
|
-
input: context.path
|
|
57
|
-
}]);
|
|
58
|
-
if (!closest || isCloser(failure, closest)) closest = failure;
|
|
59
|
-
}
|
|
60
|
-
const failed = invalidRule(this, context);
|
|
61
|
-
if (!closest || this.context.errorMessage) return failed;
|
|
62
|
-
const errors = (firstErrorOnly ? closest.errors.slice(0, 1) : closest.errors).map((error) => ({
|
|
63
|
-
error: error.error,
|
|
64
|
-
path: error.input
|
|
65
|
-
}));
|
|
66
|
-
const first = errors[0];
|
|
67
|
-
return first ? {
|
|
68
|
-
...failed,
|
|
69
|
-
error: first.error,
|
|
70
|
-
path: first.path,
|
|
71
|
-
errors
|
|
72
|
-
} : failed;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
//#endregion
|
|
77
|
-
export { unionRule };
|
|
78
|
-
//# sourceMappingURL=union.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"union.mjs","names":[],"sources":["../../../../../../../../../../../../packages/seal/src/rules/core/union.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule, ValidationResult } from \"../../types\";\nimport type { BaseValidator } from \"../../validators/base-validator\";\n\ntype MemberFailure = {\n /** Declaration order of the member, the last tie-breaker. */\n index: number;\n errors: ValidationResult[\"errors\"];\n /** Mismatched literals: each says the value is a different member. */\n literalMismatches: number;\n /** Segments in the deepest error path (`a.b.c` → 3). */\n depth: number;\n};\n\nconst describeFailure = (index: number, errors: ValidationResult[\"errors\"]): MemberFailure => ({\n index,\n errors,\n literalMismatches: errors.filter((error) => error.type === \"literal\").length,\n depth: Math.max(0, ...errors.map((error) => (error.input ? error.input.split(\".\").length : 0))),\n});\n\n/**\n * Whether `candidate` is closer to the value than `best`:\n *\n * 1. Fewest mismatched literals. A literal that does not match (`kind: \"owner\"`\n * given `\"member\"`) says the value is a different member, while any other\n * error says it is this member with a bad field.\n * 2. Fewest errors.\n * 3. Deepest error: the member matched more of the value's structure.\n * 4. Declaration order (an earlier member wins a tie).\n */\nconst isCloser = (candidate: MemberFailure, best: MemberFailure): boolean => {\n if (candidate.literalMismatches !== best.literalMismatches) {\n return candidate.literalMismatches < best.literalMismatches;\n }\n\n if (candidate.errors.length !== best.errors.length) {\n return candidate.errors.length < best.errors.length;\n }\n\n if (candidate.depth !== best.depth) {\n return candidate.depth > best.depth;\n }\n\n return candidate.index < best.index;\n};\n\n/**\n * Union rule - value must match at least one of the provided validators.\n *\n * Every member whose type matches the value is tried, in order, until one\n * passes. When none passes, the errors of the closest failed member (see\n * `isCloser`) are reported at their own paths with the `union` type: its\n * first error under `firstErrorOnly` (the default), all of them otherwise.\n * A custom union error message replaces them with a single error, as does the\n * default message when no member matches the value's type.\n */\nexport const unionRule: SchemaRule<{ validators: BaseValidator[] }> = {\n name: \"union\",\n // Runs on \"empty\" values too: `v.union([v.literal(\"\"), v.int()]).present()`\n // must still ask its members about `\"\"` instead of accepting it unchecked.\n requiresValue: false,\n defaultErrorMessage: \"Value must match one of the allowed types\",\n async validate(value: any, context) {\n // Absence is the required/present rule's question, as for `literalRule`;\n // answering it here would defeat `.optional()`.\n if (value === undefined) {\n return VALID_RULE;\n }\n\n const validators = this.context.options.validators;\n const firstErrorOnly = context.configurations?.firstErrorOnly ?? true;\n let closest: MemberFailure | undefined;\n\n // `firstErrorOnly` limits the errors reported, never the members tried:\n // several object members all match a plain object, and a later one may\n // be the member the value belongs to.\n for (const [index, validator] of validators.entries()) {\n // A member that cannot hold this type of value cannot pass.\n if (!validator.matchesType(value)) {\n continue;\n }\n\n // Each member gets its own context: a member must not see what an\n // earlier member wrote into it (an object member sets `schema`).\n const result = await validator.validate(value, { ...context });\n\n if (result.isValid) {\n // Preserve defaults, computed fields and transformations from the branch.\n return { isValid: true, data: result.data };\n }\n\n const failure = describeFailure(\n index,\n result.errors?.length\n ? result.errors\n : [{ type: \"union\", error: \"Validation failed\", input: context.path }],\n );\n\n if (!closest || isCloser(failure, closest)) {\n closest = failure;\n }\n }\n\n const failed = invalidRule(this, context);\n\n // No member matched the type, or the union has its own message.\n if (!closest || this.context.errorMessage) {\n return failed;\n }\n\n const reported = firstErrorOnly ? closest.errors.slice(0, 1) : closest.errors;\n const errors = reported.map((error) => ({ error: error.error, path: error.input }));\n const first = errors[0];\n\n return first ? { ...failed, error: first.error, path: first.path, errors } : failed;\n },\n};\n"],"mappings":";;;;AAcA,MAAM,mBAAmB,OAAe,YAAuD;CAC7F;CACA;CACA,mBAAmB,OAAO,QAAQ,UAAU,MAAM,SAAS,SAAS,CAAC,CAAC;CACtE,OAAO,KAAK,IAAI,GAAG,GAAG,OAAO,KAAK,UAAW,MAAM,QAAQ,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,CAAE,CAAC;AAChG;;;;;;;;;;;AAYA,MAAM,YAAY,WAA0B,SAAiC;CAC3E,IAAI,UAAU,sBAAsB,KAAK,mBACvC,OAAO,UAAU,oBAAoB,KAAK;CAG5C,IAAI,UAAU,OAAO,WAAW,KAAK,OAAO,QAC1C,OAAO,UAAU,OAAO,SAAS,KAAK,OAAO;CAG/C,IAAI,UAAU,UAAU,KAAK,OAC3B,OAAO,UAAU,QAAQ,KAAK;CAGhC,OAAO,UAAU,QAAQ,KAAK;AAChC;;;;;;;;;;;AAYA,MAAa,YAAyD;CACpE,MAAM;CAGN,eAAe;CACf,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAGlC,IAAI,UAAU,QACZ,OAAO;EAGT,MAAM,aAAa,KAAK,QAAQ,QAAQ;EACxC,MAAM,iBAAiB,QAAQ,gBAAgB,kBAAkB;EACjE,IAAI;EAKJ,KAAK,MAAM,CAAC,OAAO,cAAc,WAAW,QAAQ,GAAG;GAErD,IAAI,CAAC,UAAU,YAAY,KAAK,GAC9B;GAKF,MAAM,SAAS,MAAM,UAAU,SAAS,OAAO,EAAE,GAAG,QAAQ,CAAC;GAE7D,IAAI,OAAO,SAET,OAAO;IAAE,SAAS;IAAM,MAAM,OAAO;GAAK;GAG5C,MAAM,UAAU,gBACd,OACA,OAAO,QAAQ,SACX,OAAO,SACP,CAAC;IAAE,MAAM;IAAS,OAAO;IAAqB,OAAO,QAAQ;GAAK,CAAC,CACzE;GAEA,IAAI,CAAC,WAAW,SAAS,SAAS,OAAO,GACvC,UAAU;EAEd;EAEA,MAAM,SAAS,YAAY,MAAM,OAAO;EAGxC,IAAI,CAAC,WAAW,KAAK,QAAQ,cAC3B,OAAO;EAIT,MAAM,UADW,iBAAiB,QAAQ,OAAO,MAAM,GAAG,CAAC,IAAI,QAAQ,OAChD,CAAC,KAAK,WAAW;GAAE,OAAO,MAAM;GAAO,MAAM,MAAM;EAAM,EAAE;EAClF,MAAM,QAAQ,OAAO;EAErB,OAAO,QAAQ;GAAE,GAAG;GAAQ,OAAO,MAAM;GAAO,MAAM,MAAM;GAAM;EAAO,IAAI;CAC/E;AACF"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { get } from "../../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/get.mjs";
|
|
2
|
-
import "../../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/index.mjs";
|
|
3
|
-
import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
|
|
4
|
-
import "../../helpers/index.mjs";
|
|
5
|
-
|
|
6
|
-
//#region ../../packages/seal/src/rules/core/when.ts
|
|
7
|
-
/**
|
|
8
|
-
* When rule - conditional validation based on another field value
|
|
9
|
-
*/
|
|
10
|
-
const whenRule = {
|
|
11
|
-
name: "when",
|
|
12
|
-
description: "Apply conditional validation based on another field value",
|
|
13
|
-
async validate(value, context) {
|
|
14
|
-
const fieldToCheck = this.context.options.field;
|
|
15
|
-
const conditions = this.context.options.is;
|
|
16
|
-
const otherwise = this.context.options.otherwise;
|
|
17
|
-
const fieldValue = (this.context.options.scope || "global") === "global" ? get(context.allValues, fieldToCheck) : get(context.parent, fieldToCheck);
|
|
18
|
-
const fieldValueKey = String(fieldValue);
|
|
19
|
-
if (conditions[fieldValueKey]) {
|
|
20
|
-
const result = await conditions[fieldValueKey].validate(value, context);
|
|
21
|
-
if (result.isValid) return VALID_RULE;
|
|
22
|
-
this.context.errorMessage = result.errors?.[0]?.error || "Validation failed";
|
|
23
|
-
return invalidRule(this, context);
|
|
24
|
-
}
|
|
25
|
-
if (otherwise) {
|
|
26
|
-
const result = await otherwise.validate(value, context);
|
|
27
|
-
if (result.isValid) return VALID_RULE;
|
|
28
|
-
this.context.errorMessage = result.errors?.[0]?.error || "Validation failed";
|
|
29
|
-
return invalidRule(this, context);
|
|
30
|
-
}
|
|
31
|
-
return VALID_RULE;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
36
|
-
export { whenRule };
|
|
37
|
-
//# sourceMappingURL=when.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"when.mjs","names":[],"sources":["../../../../../../../../../../../../packages/seal/src/rules/core/when.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule, WhenRuleOptions } from \"../../types\";\n\n/**\n * When rule - conditional validation based on another field value\n */\nexport const whenRule: SchemaRule<WhenRuleOptions> = {\n name: \"when\",\n description: \"Apply conditional validation based on another field value\",\n async validate(value: any, context) {\n const fieldToCheck = this.context.options.field;\n const conditions = this.context.options.is;\n const otherwise = this.context.options.otherwise;\n const scope = this.context.options.scope || \"global\";\n\n const fieldValue =\n scope === \"global\" ? get(context.allValues, fieldToCheck) : get(context.parent, fieldToCheck);\n\n // Convert field value to string for key lookup\n // This handles boolean, number, and string field values\n const fieldValueKey = String(fieldValue);\n\n if (conditions[fieldValueKey]) {\n const result = await conditions[fieldValueKey].validate(value, context);\n if (result.isValid) {\n return VALID_RULE;\n }\n\n // Safe error access\n this.context.errorMessage = result.errors?.[0]?.error || \"Validation failed\";\n return invalidRule(this, context);\n }\n\n if (otherwise) {\n const result = await otherwise.validate(value, context);\n\n if (result.isValid) {\n return VALID_RULE;\n }\n\n // Safe error access\n this.context.errorMessage = result.errors?.[0]?.error || \"Validation failed\";\n return invalidRule(this, context);\n }\n\n return VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;;AAOA,MAAa,WAAwC;CACnD,MAAM;CACN,aAAa;CACb,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,eAAe,KAAK,QAAQ,QAAQ;EAC1C,MAAM,aAAa,KAAK,QAAQ,QAAQ;EACxC,MAAM,YAAY,KAAK,QAAQ,QAAQ;EAGvC,MAAM,cAFQ,KAAK,QAAQ,QAAQ,SAAS,cAGhC,WAAW,IAAI,QAAQ,WAAW,YAAY,IAAI,IAAI,QAAQ,QAAQ,YAAY;EAI9F,MAAM,gBAAgB,OAAO,UAAU;EAEvC,IAAI,WAAW,gBAAgB;GAC7B,MAAM,SAAS,MAAM,WAAW,cAAc,CAAC,SAAS,OAAO,OAAO;GACtE,IAAI,OAAO,SACT,OAAO;GAIT,KAAK,QAAQ,eAAe,OAAO,SAAS,EAAE,EAAE,SAAS;GACzD,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,IAAI,WAAW;GACb,MAAM,SAAS,MAAM,UAAU,SAAS,OAAO,OAAO;GAEtD,IAAI,OAAO,SACT,OAAO;GAIT,KAAK,QAAQ,eAAe,OAAO,SAAS,EAAE,EAAE,SAAS;GACzD,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,OAAO;CACT;AACF"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
|
|
2
|
-
import "../../helpers/index.mjs";
|
|
3
|
-
|
|
4
|
-
//#region ../../packages/seal/src/rules/date/date-comparison-rules.ts
|
|
5
|
-
/**
|
|
6
|
-
* Between dates rule - date must be between start and end dates
|
|
7
|
-
*/
|
|
8
|
-
const betweenDatesRule = {
|
|
9
|
-
name: "betweenDates",
|
|
10
|
-
defaultErrorMessage: "The :input must be between :startDate and :endDate",
|
|
11
|
-
async validate(value, context) {
|
|
12
|
-
const { startDate, endDate } = this.context.options;
|
|
13
|
-
const inputDate = new Date(value);
|
|
14
|
-
if (inputDate >= startDate && inputDate <= endDate) {
|
|
15
|
-
this.context.translationParams.startDate = startDate.toISOString();
|
|
16
|
-
this.context.translationParams.endDate = endDate.toISOString();
|
|
17
|
-
return VALID_RULE;
|
|
18
|
-
}
|
|
19
|
-
return invalidRule(this, context);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Today rule - date must be exactly today
|
|
24
|
-
*/
|
|
25
|
-
const todayRule = {
|
|
26
|
-
name: "today",
|
|
27
|
-
defaultErrorMessage: "The :input must be today",
|
|
28
|
-
async validate(value, context) {
|
|
29
|
-
const today = /* @__PURE__ */ new Date();
|
|
30
|
-
today.setHours(0, 0, 0, 0);
|
|
31
|
-
const inputDate = new Date(value);
|
|
32
|
-
inputDate.setHours(0, 0, 0, 0);
|
|
33
|
-
if (inputDate.getTime() === today.getTime()) return VALID_RULE;
|
|
34
|
-
return invalidRule(this, context);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* Past rule - date must be in the past
|
|
39
|
-
*/
|
|
40
|
-
const pastRule = {
|
|
41
|
-
name: "past",
|
|
42
|
-
defaultErrorMessage: "The :input must be in the past",
|
|
43
|
-
async validate(value, context) {
|
|
44
|
-
const now = /* @__PURE__ */ new Date();
|
|
45
|
-
if (new Date(value) < now) return VALID_RULE;
|
|
46
|
-
return invalidRule(this, context);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Future rule - date must be in the future
|
|
51
|
-
*/
|
|
52
|
-
const futureRule = {
|
|
53
|
-
name: "future",
|
|
54
|
-
defaultErrorMessage: "The :input must be in the future",
|
|
55
|
-
async validate(value, context) {
|
|
56
|
-
if (value > /* @__PURE__ */ new Date()) return VALID_RULE;
|
|
57
|
-
return invalidRule(this, context);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* After today rule - date must be after today (not including today)
|
|
62
|
-
*/
|
|
63
|
-
const afterTodayRule = {
|
|
64
|
-
name: "afterToday",
|
|
65
|
-
defaultErrorMessage: "The :input must be after today",
|
|
66
|
-
async validate(value, context) {
|
|
67
|
-
const today = /* @__PURE__ */ new Date();
|
|
68
|
-
today.setHours(0, 0, 0, 0);
|
|
69
|
-
const inputDate = new Date(value);
|
|
70
|
-
inputDate.setHours(0, 0, 0, 0);
|
|
71
|
-
if (inputDate > today) return VALID_RULE;
|
|
72
|
-
return invalidRule(this, context);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
//#endregion
|
|
77
|
-
export { afterTodayRule, betweenDatesRule, futureRule, pastRule, todayRule };
|
|
78
|
-
//# sourceMappingURL=date-comparison-rules.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"date-comparison-rules.mjs","names":[],"sources":["../../../../../../../../../../../../packages/seal/src/rules/date/date-comparison-rules.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Between dates rule - date must be between start and end dates\n */\nexport const betweenDatesRule: SchemaRule<{\n startDate: Date;\n endDate: Date;\n}> = {\n name: \"betweenDates\",\n defaultErrorMessage: \"The :input must be between :startDate and :endDate\",\n async validate(value: Date, context) {\n const { startDate, endDate } = this.context.options;\n const inputDate = new Date(value);\n\n if (inputDate >= startDate && inputDate <= endDate) {\n this.context.translationParams.startDate = startDate.toISOString();\n this.context.translationParams.endDate = endDate.toISOString();\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Today rule - date must be exactly today\n */\nexport const todayRule: SchemaRule = {\n name: \"today\",\n defaultErrorMessage: \"The :input must be today\",\n async validate(value: Date, context) {\n const today = new Date();\n today.setHours(0, 0, 0, 0);\n const inputDate = new Date(value);\n inputDate.setHours(0, 0, 0, 0);\n\n if (inputDate.getTime() === today.getTime()) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Past rule - date must be in the past\n */\nexport const pastRule: SchemaRule = {\n name: \"past\",\n defaultErrorMessage: \"The :input must be in the past\",\n async validate(value: Date, context) {\n const now = new Date();\n const inputDate = new Date(value);\n\n if (inputDate < now) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Future rule - date must be in the future\n */\nexport const futureRule: SchemaRule = {\n name: \"future\",\n defaultErrorMessage: \"The :input must be in the future\",\n async validate(value: Date, context) {\n const now = new Date();\n\n if (value > now) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * After today rule - date must be after today (not including today)\n */\nexport const afterTodayRule: SchemaRule = {\n name: \"afterToday\",\n defaultErrorMessage: \"The :input must be after today\",\n async validate(value: Date, context) {\n const today = new Date();\n today.setHours(0, 0, 0, 0);\n const inputDate = new Date(value);\n inputDate.setHours(0, 0, 0, 0);\n\n if (inputDate > today) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;AAMA,MAAa,mBAGR;CACH,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,EAAE,WAAW,YAAY,KAAK,QAAQ;EAC5C,MAAM,YAAY,IAAI,KAAK,KAAK;EAEhC,IAAI,aAAa,aAAa,aAAa,SAAS;GAClD,KAAK,QAAQ,kBAAkB,YAAY,UAAU,YAAY;GACjE,KAAK,QAAQ,kBAAkB,UAAU,QAAQ,YAAY;GAC7D,OAAO;EACT;EAEA,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,YAAwB;CACnC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,wBAAQ,IAAI,KAAK;EACvB,MAAM,SAAS,GAAG,GAAG,GAAG,CAAC;EACzB,MAAM,YAAY,IAAI,KAAK,KAAK;EAChC,UAAU,SAAS,GAAG,GAAG,GAAG,CAAC;EAE7B,IAAI,UAAU,QAAQ,MAAM,MAAM,QAAQ,GACxC,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,WAAuB;CAClC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,sBAAM,IAAI,KAAK;EAGrB,IAAI,IAFkB,KAAK,KAEf,IAAI,KACd,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,aAAyB;CACpC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EAGnC,IAAI,wBAAQ,IAFI,KAEF,GACZ,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,iBAA6B;CACxC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,wBAAQ,IAAI,KAAK;EACvB,MAAM,SAAS,GAAG,GAAG,GAAG,CAAC;EACzB,MAAM,YAAY,IAAI,KAAK,KAAK;EAChC,UAAU,SAAS,GAAG,GAAG,GAAG,CAAC;EAE7B,IAAI,YAAY,OACd,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
|
|
2
|
-
import "../../helpers/index.mjs";
|
|
3
|
-
import { WEEK_DAYS } from "../../types/date-types.mjs";
|
|
4
|
-
|
|
5
|
-
//#region ../../packages/seal/src/rules/date/date-day-rules.ts
|
|
6
|
-
/**
|
|
7
|
-
* Weekend rule - date must be Saturday or Sunday
|
|
8
|
-
*/
|
|
9
|
-
const weekendRule = {
|
|
10
|
-
name: "weekend",
|
|
11
|
-
defaultErrorMessage: "The :input must be a weekend (Saturday or Sunday)",
|
|
12
|
-
async validate(value, context) {
|
|
13
|
-
const dayOfWeek = new Date(value).getDay();
|
|
14
|
-
if (dayOfWeek === 0 || dayOfWeek === 6) return VALID_RULE;
|
|
15
|
-
return invalidRule(this, context);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Weekdays rule - date must be one of specified weekdays
|
|
20
|
-
*/
|
|
21
|
-
const weekdaysRule = {
|
|
22
|
-
name: "weekdays",
|
|
23
|
-
defaultErrorMessage: "The :input must be one of: :days",
|
|
24
|
-
async validate(value, context) {
|
|
25
|
-
const dayOfWeek = new Date(value).getDay();
|
|
26
|
-
const { days } = this.context.options;
|
|
27
|
-
if (days.map((day) => WEEK_DAYS[day]).includes(dayOfWeek)) return VALID_RULE;
|
|
28
|
-
days.forEach((day) => {
|
|
29
|
-
this.context.translatableParams[day] = day;
|
|
30
|
-
});
|
|
31
|
-
return invalidRule(this, context);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Business day rule - date must be Monday-Friday (no weekends)
|
|
36
|
-
*/
|
|
37
|
-
const businessDayRule = {
|
|
38
|
-
name: "businessDay",
|
|
39
|
-
defaultErrorMessage: "The :input must be a business day",
|
|
40
|
-
async validate(value, context) {
|
|
41
|
-
const dayOfWeek = new Date(value).getDay();
|
|
42
|
-
if (dayOfWeek >= 1 && dayOfWeek <= 5) return VALID_RULE;
|
|
43
|
-
return invalidRule(this, context);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
export { businessDayRule, weekdaysRule, weekendRule };
|
|
49
|
-
//# sourceMappingURL=date-day-rules.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"date-day-rules.mjs","names":[],"sources":["../../../../../../../../../../../../packages/seal/src/rules/date/date-day-rules.ts"],"sourcesContent":["import { invalidRule, VALID_RULE } from \"../../helpers\";\nimport type { SchemaRule } from \"../../types\";\nimport type { WeekDay } from \"../../types/date-types\";\nimport { WEEK_DAYS } from \"../../types/date-types\";\n\n/**\n * Weekend rule - date must be Saturday or Sunday\n */\nexport const weekendRule: SchemaRule = {\n name: \"weekend\",\n defaultErrorMessage: \"The :input must be a weekend (Saturday or Sunday)\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const dayOfWeek = inputDate.getDay();\n\n // 0 = Sunday, 6 = Saturday\n if (dayOfWeek === 0 || dayOfWeek === 6) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * Weekday rule - date must be Monday through Friday\n */\nexport const weekdayRule: SchemaRule = {\n name: \"weekday\",\n defaultErrorMessage: \"The :input must be a weekday (Monday-Friday)\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const dayOfWeek = inputDate.getDay();\n\n // 1-5 = Monday-Friday\n if (dayOfWeek >= 1 && dayOfWeek <= 5) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Weekdays rule - date must be one of specified weekdays\n */\nexport const weekdaysRule: SchemaRule<{ days: WeekDay[] }> = {\n name: \"weekdays\",\n defaultErrorMessage: \"The :input must be one of: :days\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const dayOfWeek = inputDate.getDay();\n const { days } = this.context.options;\n\n const allowedDays = days.map((day) => WEEK_DAYS[day]);\n\n if (allowedDays.includes(dayOfWeek)) {\n return VALID_RULE;\n }\n\n days.forEach((day) => {\n this.context.translatableParams[day] = day;\n });\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Business day rule - date must be Monday-Friday (no weekends)\n */\nexport const businessDayRule: SchemaRule = {\n name: \"businessDay\",\n defaultErrorMessage: \"The :input must be a business day\",\n async validate(value: Date, context) {\n const inputDate = new Date(value);\n const dayOfWeek = inputDate.getDay();\n\n // 1-5 = Monday-Friday\n if (dayOfWeek >= 1 && dayOfWeek <= 5) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;AAQA,MAAa,cAA0B;CACrC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EAEnC,MAAM,YAAY,IADI,KAAK,KACD,CAAC,CAAC,OAAO;EAGnC,IAAI,cAAc,KAAK,cAAc,GACnC,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAwBA,MAAa,eAAgD;CAC3D,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EAEnC,MAAM,YAAY,IADI,KAAK,KACD,CAAC,CAAC,OAAO;EACnC,MAAM,EAAE,SAAS,KAAK,QAAQ;EAI9B,IAFoB,KAAK,KAAK,QAAQ,UAAU,IAElC,CAAC,CAAC,SAAS,SAAS,GAChC,OAAO;EAGT,KAAK,SAAS,QAAQ;GACpB,KAAK,QAAQ,mBAAmB,OAAO;EACzC,CAAC;EAED,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;AAKA,MAAa,kBAA8B;CACzC,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EAEnC,MAAM,YAAY,IADI,KAAK,KACD,CAAC,CAAC,OAAO;EAGnC,IAAI,aAAa,KAAK,aAAa,GACjC,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { get } from "../../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/object/get.mjs";
|
|
2
|
-
import "../../../../../node_modules/.pnpm/@mongez_reinforcements@4.0.2/node_modules/@mongez/reinforcements/esm/index.mjs";
|
|
3
|
-
import { VALID_RULE, invalidRule } from "../../helpers/validation-helpers.mjs";
|
|
4
|
-
import { isDateValue } from "../../helpers/date-helpers.mjs";
|
|
5
|
-
import "../../helpers/index.mjs";
|
|
6
|
-
|
|
7
|
-
//#region ../../packages/seal/src/rules/date/date-field-comparison-rules.ts
|
|
8
|
-
/**
|
|
9
|
-
* Before field rule - date must be < given date or field
|
|
10
|
-
* Smart detection: date value or field name
|
|
11
|
-
* Supports both global and sibling scope
|
|
12
|
-
*/
|
|
13
|
-
const beforeFieldRule = {
|
|
14
|
-
name: "beforeField",
|
|
15
|
-
description: "The date must be before the given date or field",
|
|
16
|
-
defaultErrorMessage: "The :input must be before :dateOrField",
|
|
17
|
-
async validate(value, context) {
|
|
18
|
-
const { dateOrField, scope = "global" } = this.context.options;
|
|
19
|
-
let compareDate;
|
|
20
|
-
if (isDateValue(dateOrField)) compareDate = new Date(dateOrField);
|
|
21
|
-
else {
|
|
22
|
-
const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, dateOrField);
|
|
23
|
-
if (fieldValue === void 0) return VALID_RULE;
|
|
24
|
-
compareDate = new Date(fieldValue);
|
|
25
|
-
}
|
|
26
|
-
if (new Date(value) < compareDate) return VALID_RULE;
|
|
27
|
-
return invalidRule(this, context);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* After field rule - date must be > given date or field
|
|
32
|
-
* Smart detection: date value or field name
|
|
33
|
-
* Supports both global and sibling scope
|
|
34
|
-
*/
|
|
35
|
-
const afterFieldRule = {
|
|
36
|
-
name: "afterField",
|
|
37
|
-
description: "The date must be after the given date or field",
|
|
38
|
-
defaultErrorMessage: "The :input must be after :dateOrField",
|
|
39
|
-
async validate(value, context) {
|
|
40
|
-
const { dateOrField, scope = "global" } = this.context.options;
|
|
41
|
-
let compareDate;
|
|
42
|
-
if (isDateValue(dateOrField)) {
|
|
43
|
-
compareDate = new Date(dateOrField);
|
|
44
|
-
this.context.translationParams.dateOrField = compareDate.toISOString();
|
|
45
|
-
} else {
|
|
46
|
-
const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, dateOrField);
|
|
47
|
-
if (fieldValue === void 0) return VALID_RULE;
|
|
48
|
-
compareDate = new Date(fieldValue);
|
|
49
|
-
this.context.translatableParams.dateOrField = fieldValue;
|
|
50
|
-
}
|
|
51
|
-
if (new Date(value) > compareDate) return VALID_RULE;
|
|
52
|
-
return invalidRule(this, context);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Same as field rule - date must be the same as another field's date
|
|
57
|
-
* Supports both global and sibling scope
|
|
58
|
-
*/
|
|
59
|
-
const sameAsFieldDateRule = {
|
|
60
|
-
name: "sameAsFieldDate",
|
|
61
|
-
description: "The date must be the same as another field's date",
|
|
62
|
-
defaultErrorMessage: "The :input must be the same as :field",
|
|
63
|
-
async validate(value, context) {
|
|
64
|
-
const { field, scope = "global" } = this.context.options;
|
|
65
|
-
const fieldValue = get(scope === "sibling" ? context.parent : context.allValues, field);
|
|
66
|
-
if (fieldValue === void 0 || value === void 0) {
|
|
67
|
-
this.context.translatableParams.field = fieldValue;
|
|
68
|
-
return invalidRule(this, context);
|
|
69
|
-
}
|
|
70
|
-
const inputDate = new Date(value);
|
|
71
|
-
inputDate.setHours(0, 0, 0, 0);
|
|
72
|
-
const compareDate = new Date(fieldValue);
|
|
73
|
-
compareDate.setHours(0, 0, 0, 0);
|
|
74
|
-
if (inputDate.getTime() === compareDate.getTime()) return VALID_RULE;
|
|
75
|
-
this.context.translatableParams.field = fieldValue;
|
|
76
|
-
return invalidRule(this, context);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
//#endregion
|
|
81
|
-
export { afterFieldRule, beforeFieldRule, sameAsFieldDateRule };
|
|
82
|
-
//# sourceMappingURL=date-field-comparison-rules.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"date-field-comparison-rules.mjs","names":[],"sources":["../../../../../../../../../../../../packages/seal/src/rules/date/date-field-comparison-rules.ts"],"sourcesContent":["import { get } from \"@mongez/reinforcements\";\nimport { invalidRule, VALID_RULE } from \"../../helpers\";\nimport { isDateValue } from \"../../helpers/date-helpers\";\nimport type { SchemaRule } from \"../../types\";\n\n/**\n * Before field rule - date must be < given date or field\n * Smart detection: date value or field name\n * Supports both global and sibling scope\n */\nexport const beforeFieldRule: SchemaRule<{\n dateOrField: Date | string | number;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"beforeField\",\n description: \"The date must be before the given date or field\",\n defaultErrorMessage: \"The :input must be before :dateOrField\",\n async validate(value: Date, context) {\n const { dateOrField, scope = \"global\" } = this.context.options;\n let compareDate: Date;\n\n if (isDateValue(dateOrField)) {\n // Value comparison\n compareDate = new Date(dateOrField);\n } else {\n // Field comparison\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, dateOrField as string);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n compareDate = new Date(fieldValue);\n }\n\n const inputDate = new Date(value);\n\n if (inputDate < compareDate) {\n return VALID_RULE;\n }\n return invalidRule(this, context);\n },\n};\n\n/**\n * After field rule - date must be > given date or field\n * Smart detection: date value or field name\n * Supports both global and sibling scope\n */\nexport const afterFieldRule: SchemaRule<{\n dateOrField: Date | string | number;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"afterField\",\n description: \"The date must be after the given date or field\",\n defaultErrorMessage: \"The :input must be after :dateOrField\",\n async validate(value: Date, context) {\n const { dateOrField, scope = \"global\" } = this.context.options;\n let compareDate: Date;\n\n if (isDateValue(dateOrField)) {\n // Value comparison\n compareDate = new Date(dateOrField);\n this.context.translationParams.dateOrField = compareDate.toISOString();\n } else {\n // Field comparison\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, dateOrField as string);\n\n if (fieldValue === undefined) {\n return VALID_RULE;\n }\n\n compareDate = new Date(fieldValue);\n this.context.translatableParams.dateOrField = fieldValue;\n }\n\n const inputDate = new Date(value);\n\n if (inputDate > compareDate) {\n return VALID_RULE;\n }\n\n return invalidRule(this, context);\n },\n};\n\n/**\n * Same as field rule - date must be the same as another field's date\n * Supports both global and sibling scope\n */\nexport const sameAsFieldDateRule: SchemaRule<{\n field: string;\n scope?: \"global\" | \"sibling\";\n}> = {\n name: \"sameAsFieldDate\",\n description: \"The date must be the same as another field's date\",\n defaultErrorMessage: \"The :input must be the same as :field\",\n async validate(value: Date, context) {\n const { field, scope = \"global\" } = this.context.options;\n const source = scope === \"sibling\" ? context.parent : context.allValues;\n const fieldValue = get(source, field);\n\n // Both fields must exist to be considered \"the same\"\n if (fieldValue === undefined || value === undefined) {\n this.context.translatableParams.field = fieldValue;\n return invalidRule(this, context);\n }\n\n const inputDate = new Date(value);\n inputDate.setHours(0, 0, 0, 0);\n const compareDate = new Date(fieldValue);\n compareDate.setHours(0, 0, 0, 0);\n\n if (inputDate.getTime() === compareDate.getTime()) {\n return VALID_RULE;\n }\n\n this.context.translatableParams.field = fieldValue;\n return invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;;;;;AAUA,MAAa,kBAGR;CACH,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,EAAE,aAAa,QAAQ,aAAa,KAAK,QAAQ;EACvD,IAAI;EAEJ,IAAI,YAAY,WAAW,GAEzB,cAAc,IAAI,KAAK,WAAW;OAC7B;GAGL,MAAM,aAAa,IADJ,UAAU,YAAY,QAAQ,SAAS,QAAQ,WAC/B,WAAqB;GAEpD,IAAI,eAAe,QACjB,OAAO;GAGT,cAAc,IAAI,KAAK,UAAU;EACnC;EAIA,IAAI,IAFkB,KAAK,KAEf,IAAI,aACd,OAAO;EAET,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;;;AAOA,MAAa,iBAGR;CACH,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,EAAE,aAAa,QAAQ,aAAa,KAAK,QAAQ;EACvD,IAAI;EAEJ,IAAI,YAAY,WAAW,GAAG;GAE5B,cAAc,IAAI,KAAK,WAAW;GAClC,KAAK,QAAQ,kBAAkB,cAAc,YAAY,YAAY;EACvE,OAAO;GAGL,MAAM,aAAa,IADJ,UAAU,YAAY,QAAQ,SAAS,QAAQ,WAC/B,WAAqB;GAEpD,IAAI,eAAe,QACjB,OAAO;GAGT,cAAc,IAAI,KAAK,UAAU;GACjC,KAAK,QAAQ,mBAAmB,cAAc;EAChD;EAIA,IAAI,IAFkB,KAAK,KAEf,IAAI,aACd,OAAO;EAGT,OAAO,YAAY,MAAM,OAAO;CAClC;AACF;;;;;AAMA,MAAa,sBAGR;CACH,MAAM;CACN,aAAa;CACb,qBAAqB;CACrB,MAAM,SAAS,OAAa,SAAS;EACnC,MAAM,EAAE,OAAO,QAAQ,aAAa,KAAK,QAAQ;EAEjD,MAAM,aAAa,IADJ,UAAU,YAAY,QAAQ,SAAS,QAAQ,WAC/B,KAAK;EAGpC,IAAI,eAAe,UAAa,UAAU,QAAW;GACnD,KAAK,QAAQ,mBAAmB,QAAQ;GACxC,OAAO,YAAY,MAAM,OAAO;EAClC;EAEA,MAAM,YAAY,IAAI,KAAK,KAAK;EAChC,UAAU,SAAS,GAAG,GAAG,GAAG,CAAC;EAC7B,MAAM,cAAc,IAAI,KAAK,UAAU;EACvC,YAAY,SAAS,GAAG,GAAG,GAAG,CAAC;EAE/B,IAAI,UAAU,QAAQ,MAAM,YAAY,QAAQ,GAC9C,OAAO;EAGT,KAAK,QAAQ,mBAAmB,QAAQ;EACxC,OAAO,YAAY,MAAM,OAAO;CAClC;AACF"}
|