@cratis/arc 22.13.1 → 22.14.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/README.md +5 -4
- package/dist/cjs/Globals.js.map +1 -1
- package/dist/cjs/UrlHelpers.js.map +1 -1
- package/dist/cjs/commands/Command.js.map +1 -1
- package/dist/cjs/commands/CommandResult.js.map +1 -1
- package/dist/cjs/commands/CommandResults.js.map +1 -1
- package/dist/cjs/commands/CommandValidator.js.map +1 -1
- package/dist/cjs/commands/index.js.map +1 -1
- package/dist/cjs/deepEqual.js.map +1 -1
- package/dist/cjs/identity/IIdentityProvider.js.map +1 -1
- package/dist/cjs/identity/IdentityProvider.js.map +1 -1
- package/dist/cjs/identity/index.js.map +1 -1
- package/dist/cjs/joinPaths.js.map +1 -1
- package/dist/cjs/messaging/IMessenger.js.map +1 -1
- package/dist/cjs/messaging/Message.js.map +1 -1
- package/dist/cjs/messaging/Messenger.js.map +1 -1
- package/dist/cjs/messaging/index.js.map +1 -1
- package/dist/cjs/queries/HubConnectionKeepAlive.js.map +1 -1
- package/dist/cjs/queries/IQueryProvider.js.map +1 -1
- package/dist/cjs/queries/NullObservableQueryConnection.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryConnection.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryConnectionFactory.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryConnectionPool.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryDiagnostics.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryFor.js.map +1 -1
- package/dist/cjs/queries/ObservableQueryMultiplexer.js.map +1 -1
- package/dist/cjs/queries/ObservableQuerySubscription.js.map +1 -1
- package/dist/cjs/queries/Paging.js.map +1 -1
- package/dist/cjs/queries/PagingInfo.js.map +1 -1
- package/dist/cjs/queries/QueryFor.js.map +1 -1
- package/dist/cjs/queries/QueryHttpMethod.js.map +1 -1
- package/dist/cjs/queries/QueryHttpMethodResolver.js.map +1 -1
- package/dist/cjs/queries/QueryHttpRequest.js.map +1 -1
- package/dist/cjs/queries/QueryInstanceCache.js.map +1 -1
- package/dist/cjs/queries/QueryProvider.js.map +1 -1
- package/dist/cjs/queries/QueryResult.js.map +1 -1
- package/dist/cjs/queries/QueryResultWithState.js.map +1 -1
- package/dist/cjs/queries/QueryTransportMethod.js.map +1 -1
- package/dist/cjs/queries/QueryValidator.js.map +1 -1
- package/dist/cjs/queries/ReconnectPolicy.js.map +1 -1
- package/dist/cjs/queries/ServerSentEventHubConnection.js.map +1 -1
- package/dist/cjs/queries/ServerSentEventQueryConnection.js.map +1 -1
- package/dist/cjs/queries/SortDirection.js.map +1 -1
- package/dist/cjs/queries/Sorting.js.map +1 -1
- package/dist/cjs/queries/SortingActions.js.map +1 -1
- package/dist/cjs/queries/SortingActionsForObservableQuery.js.map +1 -1
- package/dist/cjs/queries/SortingActionsForQuery.js.map +1 -1
- package/dist/cjs/queries/ValidateRequestArguments.js.map +1 -1
- package/dist/cjs/queries/WebSocketHubConnection.js.map +1 -1
- package/dist/cjs/queries/WebSocketMessage.js.map +1 -1
- package/dist/cjs/queries/deserializeQueryModel.js.map +1 -1
- package/dist/cjs/queries/index.js.map +1 -1
- package/dist/cjs/queries/isAbortError.js.map +1 -1
- package/dist/cjs/queries/reconcileQueryData.js.map +1 -1
- package/dist/cjs/reflection/ParameterDescriptor.js.map +1 -1
- package/dist/cjs/reflection/ParametersHelper.js.map +1 -1
- package/dist/cjs/reflection/PropertyDescriptor.js.map +1 -1
- package/dist/cjs/reflection/index.js.map +1 -1
- package/dist/cjs/validation/PropertyRule.js.map +1 -1
- package/dist/cjs/validation/PropertyValidator.js.map +1 -1
- package/dist/cjs/validation/RuleBuilder.js.map +1 -1
- package/dist/cjs/validation/RuleBuilderExtensions.js.map +1 -1
- package/dist/cjs/validation/ValidationResult.js.map +1 -1
- package/dist/cjs/validation/ValidationResultReason.js.map +1 -1
- package/dist/cjs/validation/ValidationResultSeverity.js.map +1 -1
- package/dist/cjs/validation/Validator.js.map +1 -1
- package/dist/cjs/validation/index.js.map +1 -1
- package/dist/cjs/validation/rules/ComparisonRules.js.map +1 -1
- package/dist/cjs/validation/rules/EmailRule.js.map +1 -1
- package/dist/cjs/validation/rules/LengthRules.js.map +1 -1
- package/dist/cjs/validation/rules/NotEmptyRule.js.map +1 -1
- package/dist/cjs/validation/rules/PhoneRule.js.map +1 -1
- package/dist/cjs/validation/rules/RegexRule.js.map +1 -1
- package/dist/cjs/validation/rules/UrlRule.js.map +1 -1
- package/dist/esm/Globals.js.map +1 -1
- package/dist/esm/UrlHelpers.js.map +1 -1
- package/dist/esm/commands/Command.js.map +1 -1
- package/dist/esm/commands/CommandResult.js.map +1 -1
- package/dist/esm/commands/CommandResults.js.map +1 -1
- package/dist/esm/commands/CommandValidator.js.map +1 -1
- package/dist/esm/deepEqual.js.map +1 -1
- package/dist/esm/identity/IIdentityProvider.js.map +1 -1
- package/dist/esm/identity/IdentityProvider.js.map +1 -1
- package/dist/esm/joinPaths.js.map +1 -1
- package/dist/esm/messaging/IMessenger.js.map +1 -1
- package/dist/esm/messaging/Message.js.map +1 -1
- package/dist/esm/messaging/Messenger.js.map +1 -1
- package/dist/esm/queries/HubConnectionKeepAlive.js.map +1 -1
- package/dist/esm/queries/IQueryProvider.js.map +1 -1
- package/dist/esm/queries/NullObservableQueryConnection.js.map +1 -1
- package/dist/esm/queries/ObservableQueryConnection.js.map +1 -1
- package/dist/esm/queries/ObservableQueryConnectionFactory.js.map +1 -1
- package/dist/esm/queries/ObservableQueryConnectionPool.js.map +1 -1
- package/dist/esm/queries/ObservableQueryDiagnostics.js.map +1 -1
- package/dist/esm/queries/ObservableQueryFor.js.map +1 -1
- package/dist/esm/queries/ObservableQueryMultiplexer.js.map +1 -1
- package/dist/esm/queries/ObservableQuerySubscription.js.map +1 -1
- package/dist/esm/queries/Paging.js.map +1 -1
- package/dist/esm/queries/PagingInfo.js.map +1 -1
- package/dist/esm/queries/QueryFor.js.map +1 -1
- package/dist/esm/queries/QueryHttpMethod.js.map +1 -1
- package/dist/esm/queries/QueryHttpMethodResolver.js.map +1 -1
- package/dist/esm/queries/QueryHttpRequest.js.map +1 -1
- package/dist/esm/queries/QueryInstanceCache.js.map +1 -1
- package/dist/esm/queries/QueryProvider.js.map +1 -1
- package/dist/esm/queries/QueryResult.js.map +1 -1
- package/dist/esm/queries/QueryResultWithState.js.map +1 -1
- package/dist/esm/queries/QueryTransportMethod.js.map +1 -1
- package/dist/esm/queries/QueryValidator.js.map +1 -1
- package/dist/esm/queries/ReconnectPolicy.js.map +1 -1
- package/dist/esm/queries/ServerSentEventHubConnection.js.map +1 -1
- package/dist/esm/queries/ServerSentEventQueryConnection.js.map +1 -1
- package/dist/esm/queries/SortDirection.js.map +1 -1
- package/dist/esm/queries/Sorting.js.map +1 -1
- package/dist/esm/queries/SortingActions.js.map +1 -1
- package/dist/esm/queries/SortingActionsForObservableQuery.js.map +1 -1
- package/dist/esm/queries/SortingActionsForQuery.js.map +1 -1
- package/dist/esm/queries/ValidateRequestArguments.js.map +1 -1
- package/dist/esm/queries/WebSocketHubConnection.js.map +1 -1
- package/dist/esm/queries/WebSocketMessage.js.map +1 -1
- package/dist/esm/queries/deserializeQueryModel.js.map +1 -1
- package/dist/esm/queries/isAbortError.js.map +1 -1
- package/dist/esm/queries/reconcileQueryData.js.map +1 -1
- package/dist/esm/reflection/ParameterDescriptor.js.map +1 -1
- package/dist/esm/reflection/ParametersHelper.js.map +1 -1
- package/dist/esm/reflection/PropertyDescriptor.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/validation/PropertyRule.js.map +1 -1
- package/dist/esm/validation/PropertyValidator.js.map +1 -1
- package/dist/esm/validation/RuleBuilder.js.map +1 -1
- package/dist/esm/validation/RuleBuilderExtensions.js.map +1 -1
- package/dist/esm/validation/ValidationResult.js.map +1 -1
- package/dist/esm/validation/ValidationResultReason.js.map +1 -1
- package/dist/esm/validation/ValidationResultSeverity.js.map +1 -1
- package/dist/esm/validation/Validator.js.map +1 -1
- package/dist/esm/validation/rules/ComparisonRules.js.map +1 -1
- package/dist/esm/validation/rules/EmailRule.js.map +1 -1
- package/dist/esm/validation/rules/LengthRules.js.map +1 -1
- package/dist/esm/validation/rules/NotEmptyRule.js.map +1 -1
- package/dist/esm/validation/rules/PhoneRule.js.map +1 -1
- package/dist/esm/validation/rules/RegexRule.js.map +1 -1
- package/dist/esm/validation/rules/UrlRule.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyRule.js","sources":["../../../validation/PropertyRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { IValidationRule } from './IValidationRule';\nimport { ValidationResult } from './ValidationResult';\nimport { ValidationResultSeverity } from './ValidationResultSeverity';\n\n/**\n * Base class for property-based validation rules.\n * @template T The type being validated.\n * @template TProperty The type of the property being validated.\n */\nexport abstract class PropertyRule<T, TProperty> implements IValidationRule<T> {\n protected errorMessage: string;\n\n /**\n * Initializes a new instance of the {@link PropertyRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param defaultErrorMessage The default error message if validation fails.\n */\n constructor(\n protected readonly propertyAccessor: (instance: T) => TProperty,\n defaultErrorMessage: string\n ) {\n this.errorMessage = defaultErrorMessage;\n }\n\n /**\n * Set a custom error message for this rule.\n * @param message The custom error message.\n * @returns This rule instance for chaining.\n */\n withMessage(message: string): this {\n this.errorMessage = message;\n return this;\n }\n\n /** @inheritdoc */\n validate(instance: T, propertyName: string): ValidationResult[] {\n const value = this.propertyAccessor(instance);\n if (!this.isValid(value, instance)) {\n return [new ValidationResult(\n ValidationResultSeverity.Error,\n this.errorMessage.replace('{PropertyName}', propertyName),\n [propertyName],\n null\n )];\n }\n return [];\n }\n\n /**\n * Determine if the property value is valid.\n * @param value The property value.\n * @param instance The instance being validated.\n * @returns True if valid, false otherwise.\n */\n protected abstract isValid(value: TProperty, instance: T): boolean;\n}\n"],"names":["PropertyRule","errorMessage","propertyAccessor","defaultErrorMessage","withMessage","message","validate","instance","propertyName","value","isValid","ValidationResult","ValidationResultSeverity","Error","replace"],"mappings":";;;AAAA;AACA;AAMA;;;;AAIC,IACM,MAAeA,YAAAA,CAAAA;;IACRC,YAAAA;AAEV;;;;AAIC,QACD,WAAA,CACuBC,gBAA4C,EAC/DC,mBAA2B,CAC7B;aAFqBD,gBAAAA,GAAAA,gBAAAA;QAGnB,IAAI,CAACD,YAAY,GAAGE,mBAAAA;AACxB,IAAA;AAEA;;;;QAKAC,WAAAA,CAAYC,OAAe,EAAQ;QAC/B,IAAI,CAACJ,YAAY,GAAGI,OAAAA;AACpB,QAAA,OAAO,IAAI;AACf,IAAA;AAEA,uBACAC,QAAAA,CAASC,QAAW,EAAEC,YAAoB,EAAsB;AAC5D,QAAA,MAAMC,KAAAA,GAAQ,IAAI,CAACP,gBAAgB,CAACK,QAAAA,CAAAA;AACpC,QAAA,IAAI,CAAC,IAAI,CAACG,OAAO,CAACD,OAAOF,QAAAA,CAAAA,EAAW;YAChC,OAAO;gBAAC,IAAII,gBAAAA,CACRC,wBAAAA,CAAyBC,KAAK,EAC9B,IAAI,CAACZ,YAAY,CAACa,OAAO,CAAC,gBAAA,EAAkBN,YAAAA,CAAAA,EAC5C;AAACA,oBAAAA;iBAAa,EACd,IAAA;AACF,aAAA;AACN,QAAA;AACA,QAAA,OAAO,EAAE;AACb,IAAA;AASJ
|
|
1
|
+
{"version":3,"file":"PropertyRule.js","sources":["../../../validation/PropertyRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { IValidationRule } from './IValidationRule';\nimport { ValidationResult } from './ValidationResult';\nimport { ValidationResultSeverity } from './ValidationResultSeverity';\n\n/**\n * Base class for property-based validation rules.\n * @template T The type being validated.\n * @template TProperty The type of the property being validated.\n */\nexport abstract class PropertyRule<T, TProperty> implements IValidationRule<T> {\n protected errorMessage: string;\n\n /**\n * Initializes a new instance of the {@link PropertyRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param defaultErrorMessage The default error message if validation fails.\n */\n constructor(\n protected readonly propertyAccessor: (instance: T) => TProperty,\n defaultErrorMessage: string\n ) {\n this.errorMessage = defaultErrorMessage;\n }\n\n /**\n * Set a custom error message for this rule.\n * @param message The custom error message.\n * @returns This rule instance for chaining.\n */\n withMessage(message: string): this {\n this.errorMessage = message;\n return this;\n }\n\n /** @inheritdoc */\n validate(instance: T, propertyName: string): ValidationResult[] {\n const value = this.propertyAccessor(instance);\n if (!this.isValid(value, instance)) {\n return [new ValidationResult(\n ValidationResultSeverity.Error,\n this.errorMessage.replace('{PropertyName}', propertyName),\n [propertyName],\n null\n )];\n }\n return [];\n }\n\n /**\n * Determine if the property value is valid.\n * @param value The property value.\n * @param instance The instance being validated.\n * @returns True if valid, false otherwise.\n */\n protected abstract isValid(value: TProperty, instance: T): boolean;\n}\n"],"names":["PropertyRule","errorMessage","propertyAccessor","defaultErrorMessage","withMessage","message","validate","instance","propertyName","value","isValid","ValidationResult","ValidationResultSeverity","Error","replace"],"mappings":";;;AAAA;AACA;AAMA;;;;AAIC,IACM,MAAeA,YAAAA,CAAAA;;IACRC,YAAAA;AAEV;;;;AAIC,QACD,WAAA,CACuBC,gBAA4C,EAC/DC,mBAA2B,CAC7B;aAFqBD,gBAAAA,GAAAA,gBAAAA;QAGnB,IAAI,CAACD,YAAY,GAAGE,mBAAAA;AACxB,IAAA;AAEA;;;;QAKAC,WAAAA,CAAYC,OAAe,EAAQ;QAC/B,IAAI,CAACJ,YAAY,GAAGI,OAAAA;AACpB,QAAA,OAAO,IAAI;AACf,IAAA;AAEA,uBACAC,QAAAA,CAASC,QAAW,EAAEC,YAAoB,EAAsB;AAC5D,QAAA,MAAMC,KAAAA,GAAQ,IAAI,CAACP,gBAAgB,CAACK,QAAAA,CAAAA;AACpC,QAAA,IAAI,CAAC,IAAI,CAACG,OAAO,CAACD,OAAOF,QAAAA,CAAAA,EAAW;YAChC,OAAO;gBAAC,IAAII,gBAAAA,CACRC,wBAAAA,CAAyBC,KAAK,EAC9B,IAAI,CAACZ,YAAY,CAACa,OAAO,CAAC,gBAAA,EAAkBN,YAAAA,CAAAA,EAC5C;AAACA,oBAAAA;iBAAa,EACd,IAAA;AACF,aAAA;AACN,QAAA;AACA,QAAA,OAAO,EAAE;AACb,IAAA;AASJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyValidator.js","sources":["../../../validation/PropertyValidator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { IValidationRule } from './IValidationRule';\nimport { ValidationResult } from './ValidationResult';\n\n/**\n * Represents a validator for a specific property.\n * @template T The type being validated.\n */\nexport class PropertyValidator<T> {\n private readonly _rules: IValidationRule<T>[] = [];\n\n /**\n * Initializes a new instance of the {@link PropertyValidator} class.\n * @param propertyName The name of the property being validated.\n */\n constructor(readonly propertyName: string) {\n }\n\n /**\n * Add a validation rule to this property validator.\n * @param rule The rule to add.\n */\n addRule(rule: IValidationRule<T>): void {\n this._rules.push(rule);\n }\n\n /**\n * Validate the property value.\n * @param instance The instance being validated.\n * @returns An array of validation results, empty if valid.\n */\n validate(instance: T): ValidationResult[] {\n const results: ValidationResult[] = [];\n for (const rule of this._rules) {\n const ruleResults = rule.validate(instance, this.propertyName);\n results.push(...ruleResults);\n }\n return results;\n }\n\n /**\n * Gets whether or not the property is valid.\n * @param instance The instance being validated.\n * @returns True if valid, false otherwise.\n */\n isValid(instance: T): boolean {\n return this.validate(instance).length === 0;\n }\n}\n"],"names":["PropertyValidator","_rules","propertyName","addRule","rule","push","validate","instance","results","ruleResults","isValid","length"],"mappings":"AAAA;AACA;AAKA;;;AAGC,IACM,MAAMA,iBAAAA,CAAAA;;AACQC,IAAAA,MAAAA,GAA+B,EAAE;AAElD;;;QAIA,WAAA,CAAY,YAA6B,CAAE;aAAtBC,YAAAA,GAAAA,YAAAA;AACrB,IAAA;AAEA;;;QAIAC,OAAAA,CAAQC,IAAwB,EAAQ;AACpC,QAAA,IAAI,CAACH,MAAM,CAACI,IAAI,CAACD,IAAAA,CAAAA;AACrB,IAAA;AAEA;;;;QAKAE,QAAAA,CAASC,QAAW,EAAsB;AACtC,QAAA,MAAMC,UAA8B,EAAE;AACtC,QAAA,KAAK,MAAMJ,IAAAA,IAAQ,IAAI,CAACH,MAAM,CAAE;AAC5B,YAAA,MAAMQ,cAAcL,IAAAA,CAAKE,QAAQ,CAACC,QAAAA,EAAU,IAAI,CAACL,YAAY,CAAA;AAC7DM,YAAAA,OAAAA,CAAQH,IAAI,CAAA,GAAII,WAAAA,CAAAA;AACpB,QAAA;QACA,OAAOD,OAAAA;AACX,IAAA;AAEA;;;;QAKAE,OAAAA,CAAQH,QAAW,EAAW;AAC1B,QAAA,OAAO,IAAI,CAACD,QAAQ,CAACC,QAAAA,CAAAA,CAAUI,MAAM,KAAK,CAAA;AAC9C,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"PropertyValidator.js","sources":["../../../validation/PropertyValidator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { IValidationRule } from './IValidationRule';\nimport { ValidationResult } from './ValidationResult';\n\n/**\n * Represents a validator for a specific property.\n * @template T The type being validated.\n */\nexport class PropertyValidator<T> {\n private readonly _rules: IValidationRule<T>[] = [];\n\n /**\n * Initializes a new instance of the {@link PropertyValidator} class.\n * @param propertyName The name of the property being validated.\n */\n constructor(readonly propertyName: string) {\n }\n\n /**\n * Add a validation rule to this property validator.\n * @param rule The rule to add.\n */\n addRule(rule: IValidationRule<T>): void {\n this._rules.push(rule);\n }\n\n /**\n * Validate the property value.\n * @param instance The instance being validated.\n * @returns An array of validation results, empty if valid.\n */\n validate(instance: T): ValidationResult[] {\n const results: ValidationResult[] = [];\n for (const rule of this._rules) {\n const ruleResults = rule.validate(instance, this.propertyName);\n results.push(...ruleResults);\n }\n return results;\n }\n\n /**\n * Gets whether or not the property is valid.\n * @param instance The instance being validated.\n * @returns True if valid, false otherwise.\n */\n isValid(instance: T): boolean {\n return this.validate(instance).length === 0;\n }\n}\n"],"names":["PropertyValidator","_rules","propertyName","addRule","rule","push","validate","instance","results","ruleResults","isValid","length"],"mappings":"AAAA;AACA;AAKA;;;AAGC,IACM,MAAMA,iBAAAA,CAAAA;;AACQC,IAAAA,MAAAA,GAA+B,EAAE;AAElD;;;QAIA,WAAA,CAAY,YAA6B,CAAE;aAAtBC,YAAAA,GAAAA,YAAAA;AACrB,IAAA;AAEA;;;QAIAC,OAAAA,CAAQC,IAAwB,EAAQ;AACpC,QAAA,IAAI,CAACH,MAAM,CAACI,IAAI,CAACD,IAAAA,CAAAA;AACrB,IAAA;AAEA;;;;QAKAE,QAAAA,CAASC,QAAW,EAAsB;AACtC,QAAA,MAAMC,UAA8B,EAAE;AACtC,QAAA,KAAK,MAAMJ,IAAAA,IAAQ,IAAI,CAACH,MAAM,CAAE;AAC5B,YAAA,MAAMQ,cAAcL,IAAAA,CAAKE,QAAQ,CAACC,QAAAA,EAAU,IAAI,CAACL,YAAY,CAAA;AAC7DM,YAAAA,OAAAA,CAAQH,IAAI,CAAA,GAAII,WAAAA,CAAAA;AACpB,QAAA;QACA,OAAOD,OAAAA;AACX,IAAA;AAEA;;;;QAKAE,OAAAA,CAAQH,QAAW,EAAW;AAC1B,QAAA,OAAO,IAAI,CAACD,QAAQ,CAACC,QAAAA,CAAAA,CAAUI,MAAM,KAAK,CAAA;AAC9C,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuleBuilder.js","sources":["../../../validation/RuleBuilder.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyValidator } from './PropertyValidator';\nimport { IValidationRule } from './IValidationRule';\nimport { PropertyRule } from './PropertyRule';\n\n/**\n * Represents a builder for creating validation rules for a property.\n * @template T The type being validated.\n * @template TProperty The type of the property being validated.\n */\nexport class RuleBuilder<T, TProperty> {\n private lastRule?: IValidationRule<T>;\n\n /**\n * Initializes a new instance of the {@link RuleBuilder} class.\n * @param propertyValidator The property validator to add rules to.\n * @param _propertyAccessor Function to access the property value.\n */\n constructor(\n private readonly propertyValidator: PropertyValidator<T>,\n private readonly _propertyAccessor: (instance: T) => TProperty\n ) {\n }\n\n /**\n * Add a custom validation rule.\n * @param rule The validation rule to add.\n * @returns The rule builder for chaining.\n */\n addRule(rule: IValidationRule<T>): RuleBuilder<T, TProperty> {\n this.propertyValidator.addRule(rule);\n this.lastRule = rule;\n return this;\n }\n\n /**\n * Set a custom error message for the last added rule.\n * @param message The custom error message.\n * @returns The rule builder for chaining.\n */\n withMessage(message: string): RuleBuilder<T, TProperty> {\n if (this.lastRule && this.lastRule instanceof PropertyRule) {\n this.lastRule.withMessage(message);\n }\n return this;\n }\n}\n"],"names":["RuleBuilder","lastRule","_propertyAccessor","propertyValidator","addRule","rule","withMessage","message","PropertyRule"],"mappings":";;AAAA;AACA;AAMA;;;;AAIC,IACM,MAAMA,WAAAA,CAAAA;;;IACDC,QAAAA;AAER;;;;AAIC,QACD,YACI,iBAAwD,EACvCC,iBAA6C,CAChE;aAFmBC,iBAAAA,GAAAA,iBAAAA;aACAD,iBAAAA,GAAAA,iBAAAA;AAErB,IAAA;AAEA;;;;QAKAE,OAAAA,CAAQC,IAAwB,EAA6B;AACzD,QAAA,IAAI,CAACF,iBAAiB,CAACC,OAAO,CAACC,IAAAA,CAAAA;QAC/B,IAAI,CAACJ,QAAQ,GAAGI,IAAAA;AAChB,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;;;QAKAC,WAAAA,CAAYC,OAAe,EAA6B;QACpD,IAAI,IAAI,CAACN,QAAQ,IAAI,IAAI,CAACA,QAAQ,YAAYO,YAAAA,EAAc;AACxD,YAAA,IAAI,CAACP,QAAQ,CAACK,WAAW,CAACC,OAAAA,CAAAA;AAC9B,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"RuleBuilder.js","sources":["../../../validation/RuleBuilder.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyValidator } from './PropertyValidator';\nimport { IValidationRule } from './IValidationRule';\nimport { PropertyRule } from './PropertyRule';\n\n/**\n * Represents a builder for creating validation rules for a property.\n * @template T The type being validated.\n * @template TProperty The type of the property being validated.\n */\nexport class RuleBuilder<T, TProperty> {\n private lastRule?: IValidationRule<T>;\n\n /**\n * Initializes a new instance of the {@link RuleBuilder} class.\n * @param propertyValidator The property validator to add rules to.\n * @param _propertyAccessor Function to access the property value.\n */\n constructor(\n private readonly propertyValidator: PropertyValidator<T>,\n private readonly _propertyAccessor: (instance: T) => TProperty\n ) {\n }\n\n /**\n * Add a custom validation rule.\n * @param rule The validation rule to add.\n * @returns The rule builder for chaining.\n */\n addRule(rule: IValidationRule<T>): RuleBuilder<T, TProperty> {\n this.propertyValidator.addRule(rule);\n this.lastRule = rule;\n return this;\n }\n\n /**\n * Set a custom error message for the last added rule.\n * @param message The custom error message.\n * @returns The rule builder for chaining.\n */\n withMessage(message: string): RuleBuilder<T, TProperty> {\n if (this.lastRule && this.lastRule instanceof PropertyRule) {\n this.lastRule.withMessage(message);\n }\n return this;\n }\n}\n"],"names":["RuleBuilder","lastRule","_propertyAccessor","propertyValidator","addRule","rule","withMessage","message","PropertyRule"],"mappings":";;AAAA;AACA;AAMA;;;;AAIC,IACM,MAAMA,WAAAA,CAAAA;;;IACDC,QAAAA;AAER;;;;AAIC,QACD,YACI,iBAAwD,EACvCC,iBAA6C,CAChE;aAFmBC,iBAAAA,GAAAA,iBAAAA;aACAD,iBAAAA,GAAAA,iBAAAA;AAErB,IAAA;AAEA;;;;QAKAE,OAAAA,CAAQC,IAAwB,EAA6B;AACzD,QAAA,IAAI,CAACF,iBAAiB,CAACC,OAAO,CAACC,IAAAA,CAAAA;QAC/B,IAAI,CAACJ,QAAQ,GAAGI,IAAAA;AAChB,QAAA,OAAO,IAAI;AACf,IAAA;AAEA;;;;QAKAC,WAAAA,CAAYC,OAAe,EAA6B;QACpD,IAAI,IAAI,CAACN,QAAQ,IAAI,IAAI,CAACA,QAAQ,YAAYO,YAAAA,EAAc;AACxD,YAAA,IAAI,CAACP,QAAQ,CAACK,WAAW,CAACC,OAAAA,CAAAA;AAC9B,QAAA;AACA,QAAA,OAAO,IAAI;AACf,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuleBuilderExtensions.js","sources":["../../../validation/RuleBuilderExtensions.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { RuleBuilder } from './RuleBuilder';\nimport { NotEmptyRule, NotNullRule } from './rules/NotEmptyRule';\nimport { MinLengthRule, MaxLengthRule, LengthRule } from './rules/LengthRules';\nimport { EmailRule } from './rules/EmailRule';\nimport { PhoneRule } from './rules/PhoneRule';\nimport { UrlRule } from './rules/UrlRule';\nimport { RegexRule } from './rules/RegexRule';\nimport { GreaterThanRule, GreaterThanOrEqualRule, LessThanRule, LessThanOrEqualRule } from './rules/ComparisonRules';\n\n/**\n * Extension methods for {@link RuleBuilder} to add validation rules in a fluent manner.\n */\n\n/**\n * Add a rule that the property must not be empty (not null, undefined, empty string, or empty array).\n * @template T The type being validated.\n * @template TProperty The type of the property.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function notEmpty<T, TProperty>(this: RuleBuilder<T, TProperty>): RuleBuilder<T, TProperty> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => TProperty })._propertyAccessor;\n return this.addRule(new NotEmptyRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the property must not be null or undefined.\n * @template T The type being validated.\n * @template TProperty The type of the property.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function notNull<T, TProperty>(this: RuleBuilder<T, TProperty>): RuleBuilder<T, TProperty> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => TProperty })._propertyAccessor;\n return this.addRule(new NotNullRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the string property must have at least the specified length.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param length The minimum length.\n * @returns The rule builder for chaining.\n */\nexport function minLength<T>(this: RuleBuilder<T, string>, length: number): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new MinLengthRule<T>(propertyAccessor, length));\n}\n\n/**\n * Add a rule that the string property must have at most the specified length.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param length The maximum length.\n * @returns The rule builder for chaining.\n */\nexport function maxLength<T>(this: RuleBuilder<T, string>, length: number): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new MaxLengthRule<T>(propertyAccessor, length));\n}\n\n/**\n * Add a rule that the string property must have a length between min and max.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param min The minimum length.\n * @param max The maximum length.\n * @returns The rule builder for chaining.\n */\nexport function length<T>(this: RuleBuilder<T, string>, min: number, max: number): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new LengthRule<T>(propertyAccessor, min, max));\n}\n\n/**\n * Add a rule that the string property must be a valid email address.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function emailAddress<T>(this: RuleBuilder<T, string>): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new EmailRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the string property must be a valid phone number.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function phone<T>(this: RuleBuilder<T, string>): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new PhoneRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the string property must be a valid URL.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function url<T>(this: RuleBuilder<T, string>): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new UrlRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the string property must match the specified regular expression.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param pattern The regular expression pattern.\n * @param errorMessage Optional error message.\n * @returns The rule builder for chaining.\n */\nexport function matches<T>(this: RuleBuilder<T, string>, pattern: RegExp, errorMessage?: string): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new RegexRule<T>(propertyAccessor, pattern, errorMessage));\n}\n\n/**\n * Add a rule that the number property must be greater than the specified value.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param threshold The value to compare against.\n * @returns The rule builder for chaining.\n */\nexport function greaterThan<T>(this: RuleBuilder<T, number>, threshold: number): RuleBuilder<T, number> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => number })._propertyAccessor;\n return this.addRule(new GreaterThanRule<T>(propertyAccessor, threshold));\n}\n\n/**\n * Add a rule that the number property must be greater than or equal to the specified value.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param threshold The value to compare against.\n * @returns The rule builder for chaining.\n */\nexport function greaterThanOrEqual<T>(this: RuleBuilder<T, number>, threshold: number): RuleBuilder<T, number> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => number })._propertyAccessor;\n return this.addRule(new GreaterThanOrEqualRule<T>(propertyAccessor, threshold));\n}\n\n/**\n * Add a rule that the number property must be less than the specified value.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param threshold The value to compare against.\n * @returns The rule builder for chaining.\n */\nexport function lessThan<T>(this: RuleBuilder<T, number>, threshold: number): RuleBuilder<T, number> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => number })._propertyAccessor;\n return this.addRule(new LessThanRule<T>(propertyAccessor, threshold));\n}\n\n/**\n * Add a rule that the number property must be less than or equal to the specified value.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param threshold The value to compare against.\n * @returns The rule builder for chaining.\n */\nexport function lessThanOrEqual<T>(this: RuleBuilder<T, number>, threshold: number): RuleBuilder<T, number> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => number })._propertyAccessor;\n return this.addRule(new LessThanOrEqualRule<T>(propertyAccessor, threshold));\n}\n\n// Add the extension methods to the RuleBuilder prototype\nRuleBuilder.prototype.notEmpty = notEmpty;\nRuleBuilder.prototype.notNull = notNull;\n(RuleBuilder.prototype as unknown as { minLength: typeof minLength }).minLength = minLength;\n(RuleBuilder.prototype as unknown as { maxLength: typeof maxLength }).maxLength = maxLength;\n(RuleBuilder.prototype as unknown as { length: typeof length }).length = length;\n(RuleBuilder.prototype as unknown as { emailAddress: typeof emailAddress }).emailAddress = emailAddress;\n(RuleBuilder.prototype as unknown as { phone: typeof phone }).phone = phone;\n(RuleBuilder.prototype as unknown as { url: typeof url }).url = url;\n(RuleBuilder.prototype as unknown as { matches: typeof matches }).matches = matches;\n(RuleBuilder.prototype as unknown as { greaterThan: typeof greaterThan }).greaterThan = greaterThan;\n(RuleBuilder.prototype as unknown as { greaterThanOrEqual: typeof greaterThanOrEqual }).greaterThanOrEqual = greaterThanOrEqual;\n(RuleBuilder.prototype as unknown as { lessThan: typeof lessThan }).lessThan = lessThan;\n(RuleBuilder.prototype as unknown as { lessThanOrEqual: typeof lessThanOrEqual }).lessThanOrEqual = lessThanOrEqual;\n\n// Extend the RuleBuilder interface to include these methods\ndeclare module './RuleBuilder' {\n interface RuleBuilder<T, TProperty> {\n notEmpty(): RuleBuilder<T, TProperty>;\n notNull(): RuleBuilder<T, TProperty>;\n minLength(length: number): RuleBuilder<T, TProperty>;\n maxLength(length: number): RuleBuilder<T, TProperty>;\n length(min: number, max: number): RuleBuilder<T, TProperty>;\n emailAddress(): RuleBuilder<T, TProperty>;\n phone(): RuleBuilder<T, TProperty>;\n url(): RuleBuilder<T, TProperty>;\n matches(pattern: RegExp, errorMessage?: string): RuleBuilder<T, TProperty>;\n greaterThan(threshold: number): RuleBuilder<T, TProperty>;\n greaterThanOrEqual(threshold: number): RuleBuilder<T, TProperty>;\n lessThan(threshold: number): RuleBuilder<T, TProperty>;\n lessThanOrEqual(threshold: number): RuleBuilder<T, TProperty>;\n }\n}\n"],"names":["notEmpty","propertyAccessor","_propertyAccessor","addRule","NotEmptyRule","notNull","NotNullRule","minLength","length","MinLengthRule","maxLength","MaxLengthRule","min","max","LengthRule","emailAddress","EmailRule","phone","PhoneRule","url","UrlRule","matches","pattern","errorMessage","RegexRule","greaterThan","threshold","GreaterThanRule","greaterThanOrEqual","GreaterThanOrEqualRule","lessThan","LessThanRule","lessThanOrEqual","LessThanOrEqualRule","RuleBuilder","prototype"],"mappings":";;;;;;;;;AAAA;AACA;AAWA;;;;;;;;AAUC,IACM,SAASA,QAAAA,GAAAA;AACZ,IAAA,MAAMC,gBAAAA,GAAoB,IAAI,CAAkEC,iBAAiB;AACjH,IAAA,OAAO,IAAI,CAACC,OAAO,CAAC,IAAIC,YAAAA,CAAgBH,gBAAAA,CAAAA,CAAAA;AAC5C;AAEA;;;;;;AAMC,IACM,SAASI,OAAAA,GAAAA;AACZ,IAAA,MAAMJ,gBAAAA,GAAoB,IAAI,CAAkEC,iBAAiB;AACjH,IAAA,OAAO,IAAI,CAACC,OAAO,CAAC,I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AAA,CAAYC,SAAS,CAACnC,QAAQ,GAAGA,QAAAA;AACjCkC,WAAAA,CAAYC,SAAS,CAAC9B,OAAO,GAAGA,OAAAA;AAC/B6B,WAAAA,CAAYC,SAAS,CAAgD5B,SAAS,GAAGA,SAAAA;AACjF2B,WAAAA,CAAYC,SAAS,CAAgDzB,SAAS,GAAGA,SAAAA;AACjFwB,WAAAA,CAAYC,SAAS,CAA0C3B,MAAM,GAAGA,MAAAA;AACxE0B,WAAAA,CAAYC,SAAS,CAAsDpB,YAAY,GAAGA,YAAAA;AAC1FmB,WAAAA,CAAYC,SAAS,CAAwClB,KAAK,GAAGA,KAAAA;AACrEiB,WAAAA,CAAYC,SAAS,CAAoChB,GAAG,GAAGA,GAAAA;AAC/De,WAAAA,CAAYC,SAAS,CAA4Cd,OAAO,GAAGA,OAAAA;AAC3Ea,WAAAA,CAAYC,SAAS,CAAoDV,WAAW,GAAGA,WAAAA;AACvFS,WAAAA,CAAYC,SAAS,CAAkEP,kBAAkB,GAAGA,kBAAAA;AAC5GM,WAAAA,CAAYC,SAAS,CAA8CL,QAAQ,GAAGA,QAAAA;AAC9EI,WAAAA,CAAYC,SAAS,CAA4DH,eAAe,GAAGA,eAAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"RuleBuilderExtensions.js","sources":["../../../validation/RuleBuilderExtensions.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { RuleBuilder } from './RuleBuilder';\nimport { NotEmptyRule, NotNullRule } from './rules/NotEmptyRule';\nimport { MinLengthRule, MaxLengthRule, LengthRule } from './rules/LengthRules';\nimport { EmailRule } from './rules/EmailRule';\nimport { PhoneRule } from './rules/PhoneRule';\nimport { UrlRule } from './rules/UrlRule';\nimport { RegexRule } from './rules/RegexRule';\nimport { GreaterThanRule, GreaterThanOrEqualRule, LessThanRule, LessThanOrEqualRule } from './rules/ComparisonRules';\n\n/**\n * Extension methods for {@link RuleBuilder} to add validation rules in a fluent manner.\n */\n\n/**\n * Add a rule that the property must not be empty (not null, undefined, empty string, or empty array).\n * @template T The type being validated.\n * @template TProperty The type of the property.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function notEmpty<T, TProperty>(this: RuleBuilder<T, TProperty>): RuleBuilder<T, TProperty> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => TProperty })._propertyAccessor;\n return this.addRule(new NotEmptyRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the property must not be null or undefined.\n * @template T The type being validated.\n * @template TProperty The type of the property.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function notNull<T, TProperty>(this: RuleBuilder<T, TProperty>): RuleBuilder<T, TProperty> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => TProperty })._propertyAccessor;\n return this.addRule(new NotNullRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the string property must have at least the specified length.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param length The minimum length.\n * @returns The rule builder for chaining.\n */\nexport function minLength<T>(this: RuleBuilder<T, string>, length: number): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new MinLengthRule<T>(propertyAccessor, length));\n}\n\n/**\n * Add a rule that the string property must have at most the specified length.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param length The maximum length.\n * @returns The rule builder for chaining.\n */\nexport function maxLength<T>(this: RuleBuilder<T, string>, length: number): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new MaxLengthRule<T>(propertyAccessor, length));\n}\n\n/**\n * Add a rule that the string property must have a length between min and max.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param min The minimum length.\n * @param max The maximum length.\n * @returns The rule builder for chaining.\n */\nexport function length<T>(this: RuleBuilder<T, string>, min: number, max: number): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new LengthRule<T>(propertyAccessor, min, max));\n}\n\n/**\n * Add a rule that the string property must be a valid email address.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function emailAddress<T>(this: RuleBuilder<T, string>): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new EmailRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the string property must be a valid phone number.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function phone<T>(this: RuleBuilder<T, string>): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new PhoneRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the string property must be a valid URL.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @returns The rule builder for chaining.\n */\nexport function url<T>(this: RuleBuilder<T, string>): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new UrlRule<T>(propertyAccessor));\n}\n\n/**\n * Add a rule that the string property must match the specified regular expression.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param pattern The regular expression pattern.\n * @param errorMessage Optional error message.\n * @returns The rule builder for chaining.\n */\nexport function matches<T>(this: RuleBuilder<T, string>, pattern: RegExp, errorMessage?: string): RuleBuilder<T, string> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => string })._propertyAccessor;\n return this.addRule(new RegexRule<T>(propertyAccessor, pattern, errorMessage));\n}\n\n/**\n * Add a rule that the number property must be greater than the specified value.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param threshold The value to compare against.\n * @returns The rule builder for chaining.\n */\nexport function greaterThan<T>(this: RuleBuilder<T, number>, threshold: number): RuleBuilder<T, number> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => number })._propertyAccessor;\n return this.addRule(new GreaterThanRule<T>(propertyAccessor, threshold));\n}\n\n/**\n * Add a rule that the number property must be greater than or equal to the specified value.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param threshold The value to compare against.\n * @returns The rule builder for chaining.\n */\nexport function greaterThanOrEqual<T>(this: RuleBuilder<T, number>, threshold: number): RuleBuilder<T, number> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => number })._propertyAccessor;\n return this.addRule(new GreaterThanOrEqualRule<T>(propertyAccessor, threshold));\n}\n\n/**\n * Add a rule that the number property must be less than the specified value.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param threshold The value to compare against.\n * @returns The rule builder for chaining.\n */\nexport function lessThan<T>(this: RuleBuilder<T, number>, threshold: number): RuleBuilder<T, number> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => number })._propertyAccessor;\n return this.addRule(new LessThanRule<T>(propertyAccessor, threshold));\n}\n\n/**\n * Add a rule that the number property must be less than or equal to the specified value.\n * @template T The type being validated.\n * @param this The rule builder instance.\n * @param threshold The value to compare against.\n * @returns The rule builder for chaining.\n */\nexport function lessThanOrEqual<T>(this: RuleBuilder<T, number>, threshold: number): RuleBuilder<T, number> {\n const propertyAccessor = (this as unknown as { _propertyAccessor: (instance: T) => number })._propertyAccessor;\n return this.addRule(new LessThanOrEqualRule<T>(propertyAccessor, threshold));\n}\n\n// Add the extension methods to the RuleBuilder prototype\nRuleBuilder.prototype.notEmpty = notEmpty;\nRuleBuilder.prototype.notNull = notNull;\n(RuleBuilder.prototype as unknown as { minLength: typeof minLength }).minLength = minLength;\n(RuleBuilder.prototype as unknown as { maxLength: typeof maxLength }).maxLength = maxLength;\n(RuleBuilder.prototype as unknown as { length: typeof length }).length = length;\n(RuleBuilder.prototype as unknown as { emailAddress: typeof emailAddress }).emailAddress = emailAddress;\n(RuleBuilder.prototype as unknown as { phone: typeof phone }).phone = phone;\n(RuleBuilder.prototype as unknown as { url: typeof url }).url = url;\n(RuleBuilder.prototype as unknown as { matches: typeof matches }).matches = matches;\n(RuleBuilder.prototype as unknown as { greaterThan: typeof greaterThan }).greaterThan = greaterThan;\n(RuleBuilder.prototype as unknown as { greaterThanOrEqual: typeof greaterThanOrEqual }).greaterThanOrEqual = greaterThanOrEqual;\n(RuleBuilder.prototype as unknown as { lessThan: typeof lessThan }).lessThan = lessThan;\n(RuleBuilder.prototype as unknown as { lessThanOrEqual: typeof lessThanOrEqual }).lessThanOrEqual = lessThanOrEqual;\n\n// Extend the RuleBuilder interface to include these methods\ndeclare module './RuleBuilder' {\n interface RuleBuilder<T, TProperty> {\n notEmpty(): RuleBuilder<T, TProperty>;\n notNull(): RuleBuilder<T, TProperty>;\n minLength(length: number): RuleBuilder<T, TProperty>;\n maxLength(length: number): RuleBuilder<T, TProperty>;\n length(min: number, max: number): RuleBuilder<T, TProperty>;\n emailAddress(): RuleBuilder<T, TProperty>;\n phone(): RuleBuilder<T, TProperty>;\n url(): RuleBuilder<T, TProperty>;\n matches(pattern: RegExp, errorMessage?: string): RuleBuilder<T, TProperty>;\n greaterThan(threshold: number): RuleBuilder<T, TProperty>;\n greaterThanOrEqual(threshold: number): RuleBuilder<T, TProperty>;\n lessThan(threshold: number): RuleBuilder<T, TProperty>;\n lessThanOrEqual(threshold: number): RuleBuilder<T, TProperty>;\n }\n}\n"],"names":["notEmpty","propertyAccessor","_propertyAccessor","addRule","NotEmptyRule","notNull","NotNullRule","minLength","length","MinLengthRule","maxLength","MaxLengthRule","min","max","LengthRule","emailAddress","EmailRule","phone","PhoneRule","url","UrlRule","matches","pattern","errorMessage","RegexRule","greaterThan","threshold","GreaterThanRule","greaterThanOrEqual","GreaterThanOrEqualRule","lessThan","LessThanRule","lessThanOrEqual","LessThanOrEqualRule","RuleBuilder","prototype"],"mappings":";;;;;;;;;AAAA;AACA;AAWA;;;;;;;;AAUC,IACM,SAASA,QAAA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O,CAAC,IAAI4B,aAAgB9B,gBAAAA,EAAkByB,SAAAA,CAAAA,CAAAA;AAC9D;AAEA;;;;;;IAOO,SAASM,eAAAA,CAAiDN,SAAiB,EAAA;AAC9E,IAAA,MAAMzB,gBAAAA,GAAoB,IAAI,CAA+DC,iBAAiB;AAC9G,IAAA,OAAO,IAAI,CAACC,OAAO,CAAC,IAAI8B,oBAAuBhC,gBAAAA,EAAkByB,SAAAA,CAAAA,CAAAA;AACrE;AAEA;AACAQ,WAAAA,CAAYC,SAAS,CAACnC,QAAQ,GAAGA,QAAAA;AACjCkC,WAAAA,CAAYC,SAAS,CAAC9B,OAAO,GAAGA,OAAAA;AAC/B6B,WAAAA,CAAYC,SAAS,CAAgD5B,SAAS,GAAGA,SAAAA;AACjF2B,WAAAA,CAAYC,SAAS,CAAgDzB,SAAS,GAAGA,SAAAA;AACjFwB,WAAAA,CAAYC,SAAS,CAA0C3B,MAAM,GAAGA,MAAAA;AACxE0B,WAAAA,CAAYC,SAAS,CAAsDpB,YAAY,GAAGA,YAAAA;AAC1FmB,WAAAA,CAAYC,SAAS,CAAwClB,KAAK,GAAGA,KAAAA;AACrEiB,WAAAA,CAAYC,SAAS,CAAoChB,GAAG,GAAGA,GAAAA;AAC/De,WAAAA,CAAYC,SAAS,CAA4Cd,OAAO,GAAGA,OAAAA;AAC3Ea,WAAAA,CAAYC,SAAS,CAAoDV,WAAW,GAAGA,WAAAA;AACvFS,WAAAA,CAAYC,SAAS,CAAkEP,kBAAkB,GAAGA,kBAAAA;AAC5GM,WAAAA,CAAYC,SAAS,CAA8CL,QAAQ,GAAGA,QAAAA;AAC9EI,WAAAA,CAAYC,SAAS,CAA4DH,eAAe,GAAGA,eAAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationResult.js","sources":["../../../validation/ValidationResult.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ValidationResultReason } from './ValidationResultReason';\nimport { ValidationResultSeverity } from './ValidationResultSeverity';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Represents a validation error with a message for one or more members.\n */\nexport class ValidationResult {\n /**\n * Initializes a new instance of the {@link ValidationResult} class.\n * @param severity The severity of the result.\n * @param message The message. A developer diagnostic when {@link reason} is anything but `rule`.\n * @param members The members the result is attributed to.\n * @param state State associated with the result - the rule author's, carried straight through.\n * @param reason What composed the result. Defaults to `rule`, meaning an authored rule rejected the input.\n * @param reasonDetail Which specific thing within {@link reason} produced the result - the name of the violated\n * constraint for `constraintViolation`, for instance. Undefined when the reason carries no finer identity.\n * Branch on this rather than matching {@link message}, which is prose and free to change.\n */\n constructor(\n readonly severity: ValidationResultSeverity,\n readonly message: string,\n readonly members: string[],\n readonly state: any,\n readonly reason: ValidationResultReason = ValidationResultReason.Rule,\n readonly reasonDetail?: string) {\n }\n}\n"],"names":["ValidationResult","reason","ValidationResultReason","Rule","reasonDetail","severity","message","members","state"],"mappings":";;AAAA;AACA;AAKA;;AAIC,IACM,MAAMA,gBAAAA,CAAAA;;;;;;;AACT;;;;;;;;;;QAWA,WAAA,CACI,QAA2C,EAC3C,OAAwB,EACxB,OAA0B,EAC1B,KAAmB,EACnB,MAASC,GAAiCC,sBAAAA,CAAuBC,IAAI,EAC5DC,YAAqB,CAAE;aALvBC,QAAAA,GAAAA,QAAAA;aACAC,OAAAA,GAAAA,OAAAA;aACAC,OAAAA,GAAAA,OAAAA;aACAC,KAAAA,GAAAA,KAAAA;aACAP,MAAAA,GAAAA,MAAAA;aACAG,YAAAA,GAAAA,YAAAA;AACb,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"ValidationResult.js","sources":["../../../validation/ValidationResult.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ValidationResultReason } from './ValidationResultReason';\nimport { ValidationResultSeverity } from './ValidationResultSeverity';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Represents a validation error with a message for one or more members.\n */\nexport class ValidationResult {\n /**\n * Initializes a new instance of the {@link ValidationResult} class.\n * @param severity The severity of the result.\n * @param message The message. A developer diagnostic when {@link reason} is anything but `rule`.\n * @param members The members the result is attributed to.\n * @param state State associated with the result - the rule author's, carried straight through.\n * @param reason What composed the result. Defaults to `rule`, meaning an authored rule rejected the input.\n * @param reasonDetail Which specific thing within {@link reason} produced the result - the name of the violated\n * constraint for `constraintViolation`, for instance. Undefined when the reason carries no finer identity.\n * Branch on this rather than matching {@link message}, which is prose and free to change.\n */\n constructor(\n readonly severity: ValidationResultSeverity,\n readonly message: string,\n readonly members: string[],\n readonly state: any,\n readonly reason: ValidationResultReason = ValidationResultReason.Rule,\n readonly reasonDetail?: string) {\n }\n}\n"],"names":["ValidationResult","reason","ValidationResultReason","Rule","reasonDetail","severity","message","members","state"],"mappings":";;AAAA;AACA;AAKA;;AAIC,IACM,MAAMA,gBAAAA,CAAAA;;;;;;;AACT;;;;;;;;;;QAWA,WAAA,CACI,QAA2C,EAC3C,OAAwB,EACxB,OAA0B,EAC1B,KAAmB,EACnB,MAASC,GAAiCC,sBAAAA,CAAuBC,IAAI,EAC5DC,YAAqB,CAAE;aALvBC,QAAAA,GAAAA,QAAAA;aACAC,OAAAA,GAAAA,OAAAA;aACAC,OAAAA,GAAAA,OAAAA;aACAC,KAAAA,GAAAA,KAAAA;aACAP,MAAAA,GAAAA,MAAAA;aACAG,YAAAA,GAAAA,YAAAA;AACb,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationResultReason.js","sources":["../../../validation/ValidationResultReason.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Holds the well-known values for what composed a validation result - the machine-readable counterpart to its\n * message.\n * @remarks\n * A rejection's message is a developer diagnostic, not copy to show a user. Branch on this instead of matching the\n * message, and render your own wording for anything the framework composed.\n *\n * This is deliberately not an enum. Rejections are composed in Arc, in Chronicle and in application code, so the set\n * is open: treat an unrecognized value the way you would treat {@link ValidationResultReason.Rule} rather than as an\n * error.\n */\nexport const ValidationResultReason = {\n\n /**\n * A rule authored by the application rejected the input. The message is the author's, and is meant to be shown.\n */\n Rule: 'rule',\n\n /**\n * The append was rejected because the event source moved on since it was read. Retryable - re-read and resubmit.\n */\n ConcurrencyViolation: 'concurrencyViolation',\n\n /**\n * A constraint on the event store rejected the append.\n */\n ConstraintViolation: 'constraintViolation',\n\n /**\n * A validator threw, and the framework substituted this result for the one the validator would have produced.\n * Nothing the author wrote survives, so the message is not theirs to show.\n */\n ValidatorFailed: 'validatorFailed',\n\n /**\n * Something the command needed in order to be evaluated was not available, most often the read model a\n * validator depends on. Raised before any rule ran, so nothing about the command's own rules was decided.\n */\n DependencyUnavailable: 'dependencyUnavailable',\n\n /**\n * The request itself could not be read - a malformed body, or a value that could not be bound. No rule was\n * reached.\n */\n MalformedRequest: 'malformedRequest'\n} as const;\n\n/**\n * The type of a validation result reason. Widened to string because the set is open.\n */\nexport type ValidationResultReason = string;\n"],"names":["ValidationResultReason","Rule","ConcurrencyViolation","ConstraintViolation","ValidatorFailed","DependencyUnavailable","MalformedRequest"],"mappings":"AAAA;AACA;AAEA;;;;;;;;;;UAWaA,sBAAAA,GAAyB;AAElC;;AAEC,QACDC,IAAAA,EAAM,MAAA;AAEN;;AAEC,QACDC,oBAAAA,EAAsB,sBAAA;AAEtB;;AAEC,QACDC,mBAAAA,EAAqB,qBAAA;AAErB;;;AAGC,QACDC,eAAAA,EAAiB,iBAAA;AAEjB;;;AAGC,QACDC,qBAAAA,EAAuB,uBAAA;AAEvB;;;AAGC,QACDC,gBAAAA,EAAkB;AACtB
|
|
1
|
+
{"version":3,"file":"ValidationResultReason.js","sources":["../../../validation/ValidationResultReason.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Holds the well-known values for what composed a validation result - the machine-readable counterpart to its\n * message.\n * @remarks\n * A rejection's message is a developer diagnostic, not copy to show a user. Branch on this instead of matching the\n * message, and render your own wording for anything the framework composed.\n *\n * This is deliberately not an enum. Rejections are composed in Arc, in Chronicle and in application code, so the set\n * is open: treat an unrecognized value the way you would treat {@link ValidationResultReason.Rule} rather than as an\n * error.\n */\nexport const ValidationResultReason = {\n\n /**\n * A rule authored by the application rejected the input. The message is the author's, and is meant to be shown.\n */\n Rule: 'rule',\n\n /**\n * The append was rejected because the event source moved on since it was read. Retryable - re-read and resubmit.\n */\n ConcurrencyViolation: 'concurrencyViolation',\n\n /**\n * A constraint on the event store rejected the append.\n */\n ConstraintViolation: 'constraintViolation',\n\n /**\n * A validator threw, and the framework substituted this result for the one the validator would have produced.\n * Nothing the author wrote survives, so the message is not theirs to show.\n */\n ValidatorFailed: 'validatorFailed',\n\n /**\n * Something the command needed in order to be evaluated was not available, most often the read model a\n * validator depends on. Raised before any rule ran, so nothing about the command's own rules was decided.\n */\n DependencyUnavailable: 'dependencyUnavailable',\n\n /**\n * The request itself could not be read - a malformed body, or a value that could not be bound. No rule was\n * reached.\n */\n MalformedRequest: 'malformedRequest'\n} as const;\n\n/**\n * The type of a validation result reason. Widened to string because the set is open.\n */\nexport type ValidationResultReason = string;\n"],"names":["ValidationResultReason","Rule","ConcurrencyViolation","ConstraintViolation","ValidatorFailed","DependencyUnavailable","MalformedRequest"],"mappings":"AAAA;AACA;AAEA;;;;;;;;;;UAWaA,sBAAAA,GAAyB;AAElC;;AAEC,QACDC,IAAAA,EAAM,MAAA;AAEN;;AAEC,QACDC,oBAAAA,EAAsB,sBAAA;AAEtB;;AAEC,QACDC,mBAAAA,EAAqB,qBAAA;AAErB;;;AAGC,QACDC,eAAAA,EAAiB,iBAAA;AAEjB;;;AAGC,QACDC,qBAAAA,EAAuB,uBAAA;AAEvB;;;AAGC,QACDC,gBAAAA,EAAkB;AACtB;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationResultSeverity.js","sources":["../../../validation/ValidationResultSeverity.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Holds the values for severity of a validation result.\n */\nexport enum ValidationResultSeverity {\n\n /**\n * The validation result is unknown.\n */\n Unknown = 0,\n\n /**\n * The validation result is a warning.\n */\n Information = 1,\n\n /**\n * The validation result is a warning.\n */\n Warning = 2,\n\n /**\n * The validation result is an error.\n */\n Error = 3\n}\n"],"names":["ValidationResultSeverity"],"mappings":"AAAA;AACA;AAEA;;IAGO,IAAKA,wBAAAA,iBAAAA,SAAAA,wBAAAA,EAAAA;AAER;;QAEC,wBAAA,CAAA,wBAAA,CAAA,SAAA,CAAA,GACS,CAAA,CAAA,GAAA,SAAA;AAEV;;QAEC,wBAAA,CAAA,wBAAA,CAAA,aAAA,CAAA,GACa,CAAA,CAAA,GAAA,aAAA;AAEd;;QAEC,wBAAA,CAAA,wBAAA,CAAA,SAAA,CAAA,GACS,CAAA,CAAA,GAAA,SAAA;AAEV;;QAEC,wBAAA,CAAA,wBAAA,CAAA,OAAA,CAAA,GACO,CAAA,CAAA,GAAA,OAAA;AApBAA,IAAAA,OAAAA,wBAAAA;AAqBX,CAAA,CAAA,EAAA
|
|
1
|
+
{"version":3,"file":"ValidationResultSeverity.js","sources":["../../../validation/ValidationResultSeverity.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Holds the values for severity of a validation result.\n */\nexport enum ValidationResultSeverity {\n\n /**\n * The validation result is unknown.\n */\n Unknown = 0,\n\n /**\n * The validation result is a warning.\n */\n Information = 1,\n\n /**\n * The validation result is a warning.\n */\n Warning = 2,\n\n /**\n * The validation result is an error.\n */\n Error = 3\n}\n"],"names":["ValidationResultSeverity"],"mappings":"AAAA;AACA;AAEA;;IAGO,IAAKA,wBAAAA,iBAAAA,SAAAA,wBAAAA,EAAAA;AAER;;QAEC,wBAAA,CAAA,wBAAA,CAAA,SAAA,CAAA,GACS,CAAA,CAAA,GAAA,SAAA;AAEV;;QAEC,wBAAA,CAAA,wBAAA,CAAA,aAAA,CAAA,GACa,CAAA,CAAA,GAAA,aAAA;AAEd;;QAEC,wBAAA,CAAA,wBAAA,CAAA,SAAA,CAAA,GACS,CAAA,CAAA,GAAA,SAAA;AAEV;;QAEC,wBAAA,CAAA,wBAAA,CAAA,OAAA,CAAA,GACO,CAAA,CAAA,GAAA,OAAA;AApBAA,IAAAA,OAAAA,wBAAAA;AAqBX,CAAA,CAAA,EAAA;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Validator.js","sources":["../../../validation/Validator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ValidationResult } from './ValidationResult';\nimport { PropertyValidator } from './PropertyValidator';\nimport { RuleBuilder } from './RuleBuilder';\n\n/**\n * Represents a validator for a type that builds validation rules programmatically.\n * @template T The type being validated.\n */\nexport class Validator<T = object> {\n private readonly _propertyValidators = new Map<string, PropertyValidator<T>>();\n\n /**\n * Define validation rules for a property.\n * @template TProperty The type of the property.\n * @param propertyAccessor Function to access the property from the instance.\n * @returns A rule builder for the property.\n */\n ruleFor<TProperty>(propertyAccessor: (instance: T) => TProperty): RuleBuilder<T, TProperty> {\n const propertyName = this.getPropertyName(propertyAccessor);\n let propertyValidator = this._propertyValidators.get(propertyName);\n \n if (!propertyValidator) {\n propertyValidator = new PropertyValidator<T>(propertyName);\n this._propertyValidators.set(propertyName, propertyValidator);\n }\n\n return new RuleBuilder<T, TProperty>(propertyValidator, propertyAccessor);\n }\n\n /**\n * Validate an instance.\n * @param instance The instance to validate.\n * @returns An array of validation results, empty if valid.\n */\n validate(instance: T): ValidationResult[] {\n const results: ValidationResult[] = [];\n for (const propertyValidator of this._propertyValidators.values()) {\n const propertyResults = propertyValidator.validate(instance);\n results.push(...propertyResults);\n }\n return results;\n }\n\n /**\n * Gets whether or not the instance is valid.\n * @param instance The instance to validate.\n * @returns True if valid, false otherwise.\n */\n get isValid(): boolean {\n return true;\n }\n\n /**\n * Gets whether or not a specific instance is valid.\n * @param instance The instance to validate.\n * @returns True if valid, false otherwise.\n */\n isValidFor(instance: T): boolean {\n return this.validate(instance).length === 0;\n }\n\n private getPropertyName<TProperty>(propertyAccessor: (instance: T) => TProperty): string {\n // Create a proxy to capture property access\n const propertyNames: string[] = [];\n const proxy = new Proxy({} as Record<string, unknown>, {\n get(_target, prop) {\n if (typeof prop === 'string') {\n propertyNames.push(prop);\n }\n return undefined;\n }\n });\n\n try {\n propertyAccessor(proxy as T);\n } catch {\n // Ignore errors - we're just capturing the property name\n }\n\n return propertyNames[0] || 'unknown';\n }\n}\n"],"names":["Validator","_propertyValidators","Map","ruleFor","propertyAccessor","propertyName","getPropertyName","propertyValidator","get","PropertyValidator","set","RuleBuilder","validate","instance","results","values","propertyResults","push","isValid","isValidFor","length","propertyNames","proxy","Proxy","_target","prop","undefined"],"mappings":";;;AAAA;AACA;AAMA;;;AAGC,IACM,MAAMA,SAAAA,CAAAA;AACQC,IAAAA,mBAAAA,GAAsB,IAAIC,GAAAA,EAAAA;AAE3C;;;;;QAMAC,OAAAA,CAAmBC,gBAA4C,EAA6B;AACxF,QAAA,MAAMC,YAAAA,GAAe,IAAI,CAACC,eAAe,CAACF,gBAAAA,CAAAA;AAC1C,QAAA,IAAIG,oBAAoB,IAAI,CAACN,mBAAmB,CAACO,GAAG,CAACH,YAAAA,CAAAA;AAErD,QAAA,IAAI,CAACE,iBAAAA,EAAmB;AACpBA,YAAAA,iBAAAA,GAAoB,IAAIE,iBAAAA,CAAqBJ,YAAAA,CAAAA;AAC7C,YAAA,IAAI,CAACJ,mBAAmB,CAACS,GAAG,CAACL,YAAAA,EAAcE,iBAAAA,CAAAA;AAC/C,QAAA;QAE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served.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { ValidationResult } from './ValidationResult';\nimport { PropertyValidator } from './PropertyValidator';\nimport { RuleBuilder } from './RuleBuilder';\n\n/**\n * Represents a validator for a type that builds validation rules programmatically.\n * @template T The type being validated.\n */\nexport class Validator<T = object> {\n private readonly _propertyValidators = new Map<string, PropertyValidator<T>>();\n\n /**\n * Define validation rules for a property.\n * @template TProperty The type of the property.\n * @param propertyAccessor Function to access the property from the instance.\n * @returns A rule builder for the property.\n */\n ruleFor<TProperty>(propertyAccessor: (instance: T) => TProperty): RuleBuilder<T, TProperty> {\n const propertyName = this.getPropertyName(propertyAccessor);\n let propertyValidator = this._propertyValidators.get(propertyName);\n \n if (!propertyValidator) {\n propertyValidator = new PropertyValidator<T>(propertyName);\n this._propertyValidators.set(propertyName, propertyValidator);\n }\n\n return new RuleBuilder<T, TProperty>(propertyValidator, propertyAccessor);\n }\n\n /**\n * Validate an instance.\n * @param instance The instance to validate.\n * @returns An array of validation results, empty if valid.\n */\n validate(instance: T): ValidationResult[] {\n const results: ValidationResult[] = [];\n for (const propertyValidator of this._propertyValidators.values()) {\n const propertyResults = propertyValidator.validate(instance);\n results.push(...propertyResults);\n }\n return results;\n }\n\n /**\n * Gets whether or not the instance is valid.\n * @param instance The instance to validate.\n * @returns True if valid, false otherwise.\n */\n get isValid(): boolean {\n return true;\n }\n\n /**\n * Gets whether or not a specific instance is valid.\n * @param instance The instance to validate.\n * @returns True if valid, false otherwise.\n */\n isValidFor(instance: T): boolean {\n return this.validate(instance).length === 0;\n }\n\n private getPropertyName<TProperty>(propertyAccessor: (instance: T) => TProperty): string {\n // Create a proxy to capture property access\n const propertyNames: string[] = [];\n const proxy = new Proxy({} as Record<string, unknown>, {\n get(_target, prop) {\n if (typeof prop === 'string') {\n propertyNames.push(prop);\n }\n return undefined;\n }\n });\n\n try {\n propertyAccessor(proxy as T);\n } catch {\n // Ignore errors - we're just capturing the property name\n }\n\n return propertyNames[0] || 'unknown';\n }\n}\n"],"names":["Validator","_propertyValidators","Map","ruleFor","propertyAccessor","propertyName","getPropertyName","propertyValidator","get","PropertyValidator","set","RuleBuilder","validate","instance","results","values","propertyResults","push","isValid","isValidFor","length","propertyNames","proxy","Proxy","_target","prop","undefined"],"mappings":";;;AAAA;AACA;AAMA;;;AAGC,IACM,MAAMA,SAAAA,CAAAA;AACQC,IAAAA,mBAAAA,GAAsB,IAAIC,GAAAA,EAAAA;AAE3C;;;;;QAMAC,OAAAA,CAAmBC,gBAA4C,EAA6B;AACxF,QAAA,MAAMC,YAAAA,GAAe,IAAI,CAACC,eAAe,CAACF,gBAAAA,CAAAA;AAC1C,QAAA,IAAIG,oBAAoB,IAAI,CAACN,mBAAmB,CAACO,GAAG,CAACH,YAAAA,CAAAA;AAErD,QAAA,IAAI,CAACE,iBAAAA,EAAmB;AACpBA,YAAAA,iBAAAA,GAAoB,IAAIE,iBAAAA,CAAqBJ,YAAAA,CAAAA;AAC7C,YAAA,IAAI,CAACJ,mBAAmB,CAACS,GAAG,CAACL,YAAAA,EAAcE,iBAAAA,CAAAA;AAC/C,QAAA;QAEA,OAAO,IAAII,YAA0BJ,iBAAAA,EAAmBH,gBAAAA,CAAAA;AAC5D,IAAA;AAEA;;;;QAKAQ,QAAAA,CAASC,QAAW,EAAsB;AACtC,QAAA,MAAMC,UAA8B,EAAE;AACtC,QAAA,KAAK,MAAMP,iBAAAA,IAAqB,IAAI,CAACN,mBAAmB,CAACc,MAAM,EAAA,CAAI;YAC/D,MAAMC,eAAAA,GAAkBT,iBAAAA,CAAkBK,QAAQ,CAACC,QAAAA,CAAAA;AACnDC,YAAAA,OAAAA,CAAQG,IAAI,CAAA,GAAID,eAAAA,CAAAA;AACpB,QAAA;QACA,OAAOF,OAAAA;AACX,IAAA;AAEA;;;;AAIC,QACD,IAAII,OAAAA,GAAmB;QACnB,OAAO,IAAA;AACX,IAAA;AAEA;;;;QAKAC,UAAAA,CAAWN,QAAW,EAAW;AAC7B,QAAA,OAAO,IAAI,CAACD,QAAQ,CAACC,QAAAA,CAAAA,CAAUO,MAAM,KAAK,CAAA;AAC9C,IAAA;AAEQd,IAAAA,eAAAA,CAA2BF,gBAA4C,EAAU;;AAErF,QAAA,MAAMiB,gBAA0B,EAAE;AAClC,QAAA,MAAMC,KAAAA,GAAQ,IAAIC,KAAAA,CAAM,EAAC,EAA8B;YACnDf,GAAAA,CAAAA,CAAIgB,OAAO,EAAEC,IAAI,EAAA;gBACb,IAAI,OAAOA,SAAS,QAAA,EAAU;AAC1BJ,oBAAAA,aAAAA,CAAcJ,IAAI,CAACQ,IAAAA,CAAAA;AACvB,gBAAA;gBACA,OAAOC,SAAAA;AACX,YAAA;AACJ,SAAA,CAAA;QAEA,IAAI;YACAtB,gBAAAA,CAAiBkB,KAAAA,CAAAA;AACrB,QAAA,CAAA,CAAE,OAAM;;AAER,QAAA;QAEA,OAAOD,aAAa,CAAC,CAAA,CAAE,IAAI,SAAA;AAC/B,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComparisonRules.js","sources":["../../../../validation/rules/ComparisonRules.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a number is greater than a specified value.\n * @template T The type being validated.\n */\nexport class GreaterThanRule<T> extends PropertyRule<T, number> {\n /**\n * Initializes a new instance of the {@link GreaterThanRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param threshold The value that the property must be greater than.\n */\n constructor(propertyAccessor: (instance: T) => number, private readonly threshold: number) {\n super(propertyAccessor, `'{PropertyName}' must be greater than ${threshold}.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: number): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n return value > this.threshold;\n }\n}\n\n/**\n * Validation rule that checks if a number is greater than or equal to a specified value.\n * @template T The type being validated.\n */\nexport class GreaterThanOrEqualRule<T> extends PropertyRule<T, number> {\n /**\n * Initializes a new instance of the {@link GreaterThanOrEqualRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param threshold The value that the property must be greater than or equal to.\n */\n constructor(propertyAccessor: (instance: T) => number, private readonly threshold: number) {\n super(propertyAccessor, `'{PropertyName}' must be greater than or equal to ${threshold}.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: number): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n return value >= this.threshold;\n }\n}\n\n/**\n * Validation rule that checks if a number is less than a specified value.\n * @template T The type being validated.\n */\nexport class LessThanRule<T> extends PropertyRule<T, number> {\n /**\n * Initializes a new instance of the {@link LessThanRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param threshold The value that the property must be less than.\n */\n constructor(propertyAccessor: (instance: T) => number, private readonly threshold: number) {\n super(propertyAccessor, `'{PropertyName}' must be less than ${threshold}.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: number): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n return value < this.threshold;\n }\n}\n\n/**\n * Validation rule that checks if a number is less than or equal to a specified value.\n * @template T The type being validated.\n */\nexport class LessThanOrEqualRule<T> extends PropertyRule<T, number> {\n /**\n * Initializes a new instance of the {@link LessThanOrEqualRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param threshold The value that the property must be less than or equal to.\n */\n constructor(propertyAccessor: (instance: T) => number, private readonly threshold: number) {\n super(propertyAccessor, `'{PropertyName}' must be less than or equal to ${threshold}.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: number): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n return value <= this.threshold;\n }\n}\n"],"names":["GreaterThanRule","PropertyRule","propertyAccessor","threshold","isValid","value","undefined","GreaterThanOrEqualRule","LessThanRule","LessThanOrEqualRule"],"mappings":";;AAAA;AACA;AAIA;;;IAIO,MAAMA,eAAAA,SAA2BC,YAAAA,CAAAA;;AACpC;;;;AAIC,QACD,WAAA,CAAYC,gB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S;AACjC,IAAA;AACJ;AAEA;;;IAIO,MAAMM,mBAAAA,SAA+BR,YAAAA,CAAAA;;AACxC;;;;AAIC,QACD,WAAA,CAAYC,gBAAyC,EAAmBC,SAAiB,CAAE;QACvF,KAAK,CAACD,kBAAkB,CAAC,+CAA+C,EAAEC,SAAAA,CAAU,CAAC,CAAC,CAAA,EAAA,IAAA,CADlBA,SAAAA,GAAAA,SAAAA;AAExE,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;QACtC,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,EAAW;YACvC,OAAO,IAAA;AACX,QAAA;QACA,OAAOD,KAAAA,IAAS,IAAI,CAACF,SAAS;AAClC,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"ComparisonRules.js","sources":["../../../../validation/rules/ComparisonRules.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a number is greater than a specified value.\n * @template T The type being validated.\n */\nexport class GreaterThanRule<T> extends PropertyRule<T, number> {\n /**\n * Initializes a new instance of the {@link GreaterThanRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param threshold The value that the property must be greater than.\n */\n constructor(propertyAccessor: (instance: T) => number, private readonly threshold: number) {\n super(propertyAccessor, `'{PropertyName}' must be greater than ${threshold}.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: number): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n return value > this.threshold;\n }\n}\n\n/**\n * Validation rule that checks if a number is greater than or equal to a specified value.\n * @template T The type being validated.\n */\nexport class GreaterThanOrEqualRule<T> extends PropertyRule<T, number> {\n /**\n * Initializes a new instance of the {@link GreaterThanOrEqualRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param threshold The value that the property must be greater than or equal to.\n */\n constructor(propertyAccessor: (instance: T) => number, private readonly threshold: number) {\n super(propertyAccessor, `'{PropertyName}' must be greater than or equal to ${threshold}.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: number): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n return value >= this.threshold;\n }\n}\n\n/**\n * Validation rule that checks if a number is less than a specified value.\n * @template T The type being validated.\n */\nexport class LessThanRule<T> extends PropertyRule<T, number> {\n /**\n * Initializes a new instance of the {@link LessThanRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param threshold The value that the property must be less than.\n */\n constructor(propertyAccessor: (instance: T) => number, private readonly threshold: number) {\n super(propertyAccessor, `'{PropertyName}' must be less than ${threshold}.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: number): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n return value < this.threshold;\n }\n}\n\n/**\n * Validation rule that checks if a number is less than or equal to a specified value.\n * @template T The type being validated.\n */\nexport class LessThanOrEqualRule<T> extends PropertyRule<T, number> {\n /**\n * Initializes a new instance of the {@link LessThanOrEqualRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param threshold The value that the property must be less than or equal to.\n */\n constructor(propertyAccessor: (instance: T) => number, private readonly threshold: number) {\n super(propertyAccessor, `'{PropertyName}' must be less than or equal to ${threshold}.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: number): boolean {\n if (value === null || value === undefined) {\n return true;\n }\n return value <= this.threshold;\n }\n}\n"],"names":["GreaterThanRule","PropertyRule","propertyAccessor","threshold","isValid","value","undefined","GreaterThanOrEqualRule","LessThanRule","LessThanOrEqualRule"],"mappings":";;AAAA;AACA;AAIA;;;IAIO,MAAMA,eAAAA,SAA2BC,YAAAA,CAAAA;;AACpC;;;;AAIC,QACD,WAAA,CAAYC,gBAAyC,EAAmBC,SAAiB,CAAE;QACvF,KAAK,CAACD,kBAAkB,CAAC,sCAAsC,EAAEC,SAAAA,CAAU,CAAC,CAAC,CAAA,EAAA,IAAA,CADTA,SAAAA,GAAAA,SAAAA;AAExE,IAAA;AAEA,uBACUC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+CAA+C,EAAEC,SAAAA,CAAU,CAAC,CAAC,CAAA,EAAA,IAAA,CADlBA,SAAAA,GAAAA,SAAAA;AAExE,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;QACtC,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,EAAW;YACvC,OAAO,IAAA;AACX,QAAA;QACA,OAAOD,KAAAA,IAAS,IAAI,CAACF,SAAS;AAClC,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailRule.js","sources":["../../../../validation/rules/EmailRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a string matches an email pattern.\n * @template T The type being validated.\n */\nexport class EmailRule<T> extends PropertyRule<T, string> {\n private static readonly emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\n /**\n * Initializes a new instance of the {@link EmailRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n */\n constructor(propertyAccessor: (instance: T) => string) {\n super(propertyAccessor, \"'{PropertyName}' is not a valid email address.\");\n }\n\n /** @inheritdoc */\n protected isValid(value: string): boolean {\n if (value === null || value === undefined || value === '') {\n return true; // Use NotNull/NotEmpty for null checks\n }\n return EmailRule.emailRegex.test(value);\n }\n}\n"],"names":["EmailRule","PropertyRule","emailRegex","propertyAccessor","isValid","value","undefined","test"],"mappings":";;AAAA;AACA;AAIA;;;IAIO,MAAMA,SAAAA,SAAqBC,YAAAA,CAAAA;AAC9B,IAAA,OAAwBC,aAAa,4BAAA;AAErC;;;QAIA,WAAA,CAAYC,gBAAyC,CAAE;AACnD,QAAA,KAAK,CAACA,gBAAAA,EAAkB,gDAAA,CAAA;AAC5B,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;AACtC,QAAA,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,IAAaD,UAAU,EAAA,EAAI;AACvD,YAAA,OAAO;AACX,QAAA;AACA,QAAA,OAAOL,SAAAA,CAAUE,UAAU,CAACK,IAAI,CAACF,KAAAA,CAAAA;AACrC,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"EmailRule.js","sources":["../../../../validation/rules/EmailRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a string matches an email pattern.\n * @template T The type being validated.\n */\nexport class EmailRule<T> extends PropertyRule<T, string> {\n private static readonly emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\n /**\n * Initializes a new instance of the {@link EmailRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n */\n constructor(propertyAccessor: (instance: T) => string) {\n super(propertyAccessor, \"'{PropertyName}' is not a valid email address.\");\n }\n\n /** @inheritdoc */\n protected isValid(value: string): boolean {\n if (value === null || value === undefined || value === '') {\n return true; // Use NotNull/NotEmpty for null checks\n }\n return EmailRule.emailRegex.test(value);\n }\n}\n"],"names":["EmailRule","PropertyRule","emailRegex","propertyAccessor","isValid","value","undefined","test"],"mappings":";;AAAA;AACA;AAIA;;;IAIO,MAAMA,SAAAA,SAAqBC,YAAAA,CAAAA;AAC9B,IAAA,OAAwBC,aAAa,4BAAA;AAErC;;;QAIA,WAAA,CAAYC,gBAAyC,CAAE;AACnD,QAAA,KAAK,CAACA,gBAAAA,EAAkB,gDAAA,CAAA;AAC5B,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;AACtC,QAAA,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,IAAaD,UAAU,EAAA,EAAI;AACvD,YAAA,OAAO;AACX,QAAA;AACA,QAAA,OAAOL,SAAAA,CAAUE,UAAU,CAACK,IAAI,CAACF,KAAAA,CAAAA;AACrC,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LengthRules.js","sources":["../../../../validation/rules/LengthRules.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a string has a minimum length.\n * @template T The type being validated.\n */\nexport class MinLengthRule<T> extends PropertyRule<T, string> {\n /**\n * Initializes a new instance of the {@link MinLengthRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param minLength The minimum length required.\n */\n constructor(propertyAccessor: (instance: T) => string, private readonly minLength: number) {\n super(propertyAccessor, `'{PropertyName}' must be at least ${minLength} characters.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: string): boolean {\n if (value === null || value === undefined) {\n return true; // Use NotNull/NotEmpty for null checks\n }\n return value.length >= this.minLength;\n }\n}\n\n/**\n * Validation rule that checks if a string has a maximum length.\n * @template T The type being validated.\n */\nexport class MaxLengthRule<T> extends PropertyRule<T, string> {\n /**\n * Initializes a new instance of the {@link MaxLengthRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param maxLength The maximum length allowed.\n */\n constructor(propertyAccessor: (instance: T) => string, private readonly maxLength: number) {\n super(propertyAccessor, `'{PropertyName}' must be at most ${maxLength} characters.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: string): boolean {\n if (value === null || value === undefined) {\n return true; // Use NotNull/NotEmpty for null checks\n }\n return value.length <= this.maxLength;\n }\n}\n\n/**\n * Validation rule that checks if a string has an exact length.\n * @template T The type being validated.\n */\nexport class LengthRule<T> extends PropertyRule<T, string> {\n /**\n * Initializes a new instance of the {@link LengthRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param min The minimum length required.\n * @param max The maximum length allowed.\n */\n constructor(propertyAccessor: (instance: T) => string, private readonly min: number, private readonly max: number) {\n super(propertyAccessor, `'{PropertyName}' must be between ${min} and ${max} characters.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: string): boolean {\n if (value === null || value === undefined) {\n return true; // Use NotNull/NotEmpty for null checks\n }\n return value.length >= this.min && value.length <= this.max;\n }\n}\n"],"names":["MinLengthRule","PropertyRule","propertyAccessor","minLength","isValid","value","undefined","length","MaxLengthRule","maxLength","LengthRule","min","max"],"mappings":";;AAAA;AACA;AAIA;;;IAIO,MAAMA,aAAAA,SAAyBC,YAAAA,CAAAA;;AAClC;;;;AAIC,QACD,WAAA,CAAYC,gBAAyC,EAAmBC,SAAiB,CAAE;QACvF,KAAK,CAACD,kBAAkB,CAAC,kCAAkC,EAAEC,SAAAA,CAAU,YAAY,CAAC,CAAA,EAAA,IAAA,CADhBA,SAAAA,GAAAA,SAAAA;AAExE,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;QACtC,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,EAAW;AACvC,YAAA,OAAO;AACX,QAAA;AACA,QAAA,OAAOD,KAAAA,CAAME,MAAM,IAAI,IAAI,CAACJ,SAAS;AACzC,IAAA;AACJ;AAEA;;;IAIO,MAAMK,aAAAA,SAAyBP,YAAAA,CAAAA;;AAClC;;;;AAIC,QACD,WAAA,CAAYC,gBAAyC,EAAmBO,SAAiB,CAAE;QACvF,KAAK,CAACP,kBAAkB,CAAC,iCAAiC,EAAEO,SAAAA,CAAU,YAAY,CAAC,CAAA,EAAA,IAAA,CADfA,SAAAA,GAAAA,SAAAA;AAExE,IAAA;AAEA,uBACUL,OAAAA,CAAQC,KAAa,EAAW;QACtC,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,EAAW;AACvC,YAAA,OAAO;AACX,QAAA;AACA,QAAA,OAAOD,KAAAA,CAAME,MAAM,IAAI,IAAI,CAACE,SAAS;AACzC,IAAA;AACJ;AAEA;;;IAIO,MAAMC,UAAAA,SAAsBT,YAAAA,CAAAA;;;AAC/B;;;;;QAMA,WAAA,CAAYC,gBAAyC,EAAmBS,GAAW,EAAmBC,GAAW,CAAE;AAC/G,QAAA,KAAK,CAACV,gBAAAA,EAAkB,CAAC,iCAAiC,EAAES,GAAAA,CAAI,KAAK,EAAEC,GAAAA,CAAI,YAAY,CAAC,CAAA,EAAA,IAAA,CADpBD,GAAAA,GAAAA,UAA8BC,GAAAA,GAAAA,GAAAA;AAEtG,IAAA;AAEA,uBACUR,OAAAA,CAAQC,KAAa,EAAW;QACtC,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,EAAW;AACvC,YAAA,OAAO;AACX,QAAA;AACA,QAAA,OAAOD,KAAAA,CAAME,MAAM,IAAI,IAAI,CAACI,GAAG,IAAIN,KAAAA,CAAME,MAAM,IAAI,IAAI,CAACK,GAAG;AAC/D,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"LengthRules.js","sources":["../../../../validation/rules/LengthRules.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a string has a minimum length.\n * @template T The type being validated.\n */\nexport class MinLengthRule<T> extends PropertyRule<T, string> {\n /**\n * Initializes a new instance of the {@link MinLengthRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param minLength The minimum length required.\n */\n constructor(propertyAccessor: (instance: T) => string, private readonly minLength: number) {\n super(propertyAccessor, `'{PropertyName}' must be at least ${minLength} characters.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: string): boolean {\n if (value === null || value === undefined) {\n return true; // Use NotNull/NotEmpty for null checks\n }\n return value.length >= this.minLength;\n }\n}\n\n/**\n * Validation rule that checks if a string has a maximum length.\n * @template T The type being validated.\n */\nexport class MaxLengthRule<T> extends PropertyRule<T, string> {\n /**\n * Initializes a new instance of the {@link MaxLengthRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param maxLength The maximum length allowed.\n */\n constructor(propertyAccessor: (instance: T) => string, private readonly maxLength: number) {\n super(propertyAccessor, `'{PropertyName}' must be at most ${maxLength} characters.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: string): boolean {\n if (value === null || value === undefined) {\n return true; // Use NotNull/NotEmpty for null checks\n }\n return value.length <= this.maxLength;\n }\n}\n\n/**\n * Validation rule that checks if a string has an exact length.\n * @template T The type being validated.\n */\nexport class LengthRule<T> extends PropertyRule<T, string> {\n /**\n * Initializes a new instance of the {@link LengthRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param min The minimum length required.\n * @param max The maximum length allowed.\n */\n constructor(propertyAccessor: (instance: T) => string, private readonly min: number, private readonly max: number) {\n super(propertyAccessor, `'{PropertyName}' must be between ${min} and ${max} characters.`);\n }\n\n /** @inheritdoc */\n protected isValid(value: string): boolean {\n if (value === null || value === undefined) {\n return true; // Use NotNull/NotEmpty for null checks\n }\n return value.length >= this.min && value.length <= this.max;\n }\n}\n"],"names":["MinLengthRule","PropertyRule","propertyAccessor","minLength","isValid","value","undefined","length","MaxLengthRule","maxLength","LengthRule","min","max"],"mappings":";;AAAA;AACA;AAIA;;;IAIO,MAAMA,aAAAA,SAAyBC,YAAAA,CAAAA;;AAClC;;;;AAIC,QACD,WAAA,CAAYC,gBAAyC,EAAmBC,SAAiB,CAAE;QACvF,KAAK,CAACD,kBAAkB,CAAC,kCAAkC,EAAEC,SAAAA,CAAU,YAAY,CAAC,CAAA,EAAA,IAAA,CADhBA,SAAAA,GAAAA,SAAAA;AAExE,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;QACtC,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,EAAW;AACvC,YAAA,OAAO;AACX,QAAA;AACA,QAAA,OAAOD,KAAAA,CAAME,MAAM,IAAI,IAAI,CAACJ,SAAS;AACzC,IAAA;AACJ;AAEA;;;IAIO,MAAMK,aAAAA,SAAyBP,YAAAA,CAAAA;;AAClC;;;;AAIC,QACD,WAAA,CAAYC,gBAAyC,EAAmBO,SAAiB,CAAE;QACvF,KAAK,CAACP,kBAAkB,CAAC,iCAAiC,EAAEO,SAAAA,CAAU,YAAY,CAAC,CAAA,EAAA,IAAA,CADfA,SAAAA,GAAAA,SAAAA;AAExE,IAAA;AAEA,uBACUL,OAAAA,CAAQC,KAAa,EAAW;QACtC,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,EAAW;AACvC,YAAA,OAAO;AACX,QAAA;AACA,QAAA,OAAOD,KAAAA,CAAME,MAAM,IAAI,IAAI,CAACE,SAAS;AACzC,IAAA;AACJ;AAEA;;;IAIO,MAAMC,UAAAA,SAAsBT,YAAAA,CAAAA;;;AAC/B;;;;;QAMA,WAAA,CAAYC,gBAAyC,EAAmBS,GAAW,EAAmBC,GAAW,CAAE;AAC/G,QAAA,KAAK,CAACV,gBAAAA,EAAkB,CAAC,iCAAiC,EAAES,GAAAA,CAAI,KAAK,EAAEC,GAAAA,CAAI,YAAY,CAAC,CAAA,EAAA,IAAA,CADpBD,GAAAA,GAAAA,UAA8BC,GAAAA,GAAAA,GAAAA;AAEtG,IAAA;AAEA,uBACUR,OAAAA,CAAQC,KAAa,EAAW;QACtC,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,EAAW;AACvC,YAAA,OAAO;AACX,QAAA;AACA,QAAA,OAAOD,KAAAA,CAAME,MAAM,IAAI,IAAI,CAACI,GAAG,IAAIN,KAAAA,CAAME,MAAM,IAAI,IAAI,CAACK,GAAG;AAC/D,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotEmptyRule.js","sources":["../../../../validation/rules/NotEmptyRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a value is not null, undefined, or empty.\n * @template T The type being validated.\n */\nexport class NotEmptyRule<T> extends PropertyRule<T, unknown> {\n /**\n * Initializes a new instance of the {@link NotEmptyRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n */\n constructor(propertyAccessor: (instance: T) => unknown) {\n super(propertyAccessor, \"'{PropertyName}' must not be empty.\");\n }\n\n /** @inheritdoc */\n protected isValid(value: unknown): boolean {\n if (value === null || value === undefined) {\n return false;\n }\n if (typeof value === 'string' && value.trim() === '') {\n return false;\n }\n if (Array.isArray(value) && value.length === 0) {\n return false;\n }\n return true;\n }\n}\n\n/**\n * Validation rule that checks if a value is not null or undefined.\n * @template T The type being validated.\n */\nexport class NotNullRule<T> extends PropertyRule<T, unknown> {\n /**\n * Initializes a new instance of the {@link NotNullRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n */\n constructor(propertyAccessor: (instance: T) => unknown) {\n super(propertyAccessor, \"'{PropertyName}' must not be empty.\");\n }\n\n /** @inheritdoc */\n protected isValid(value: unknown): boolean {\n return value !== null && value !== undefined;\n }\n}\n"],"names":["NotEmptyRule","PropertyRule","propertyAccessor","isValid","value","undefined","trim","Array","isArray","length","NotNullRule"],"mappings":";;AAAA;AACA;AAIA;;;IAIO,MAAMA,YAAAA,SAAwBC,YAAAA,CAAAA;AACjC;;;QAIA,WAAA,CAAYC,gBAA0C,CAAE;AACpD,QAAA,KAAK,CAACA,gBAAAA,EAAkB,qCAAA,CAAA;AAC5B,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAc,EAAW;QACvC,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,EAAW;YACvC,OAAO,KAAA;AACX,QAAA;AACA,QAAA,IAAI,OAAOD,KAAAA,KAAU,QAAA,IAAYA,KAAAA,CAAME,IAAI,OAAO,EAAA,EAAI;YAClD,OAAO,KAAA;AACX,QAAA;AACA,QAAA,IAAIC,MAAMC,OAAO,CAACJ,UAAUA,KAAAA,CAAMK,MAAM,KAAK,CAAA,EAAG;YAC5C,OAAO,KAAA;AACX,QAAA;QACA,OAAO,IAAA;AACX,IAAA;AACJ;AAEA;;;IAIO,MAAMC,WAAAA,SAAuBT,YAAAA,CAAAA;AAChC;;;QAIA,WAAA,CAAYC,gBAA0C,CAAE;AACpD,QAAA,KAAK,CAACA,gBAAAA,EAAkB,qCAAA,CAAA;AAC5B,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAc,EAAW;QACvC,OAAOA,KAAAA,KAAU,QAAQA,KAAAA,KAAUC,SAAAA;AACvC,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"NotEmptyRule.js","sources":["../../../../validation/rules/NotEmptyRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a value is not null, undefined, or empty.\n * @template T The type being validated.\n */\nexport class NotEmptyRule<T> extends PropertyRule<T, unknown> {\n /**\n * Initializes a new instance of the {@link NotEmptyRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n */\n constructor(propertyAccessor: (instance: T) => unknown) {\n super(propertyAccessor, \"'{PropertyName}' must not be empty.\");\n }\n\n /** @inheritdoc */\n protected isValid(value: unknown): boolean {\n if (value === null || value === undefined) {\n return false;\n }\n if (typeof value === 'string' && value.trim() === '') {\n return false;\n }\n if (Array.isArray(value) && value.length === 0) {\n return false;\n }\n return true;\n }\n}\n\n/**\n * Validation rule that checks if a value is not null or undefined.\n * @template T The type being validated.\n */\nexport class NotNullRule<T> extends PropertyRule<T, unknown> {\n /**\n * Initializes a new instance of the {@link NotNullRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n */\n constructor(propertyAccessor: (instance: T) => unknown) {\n super(propertyAccessor, \"'{PropertyName}' must not be empty.\");\n }\n\n /** @inheritdoc */\n protected isValid(value: unknown): boolean {\n return value !== null && value !== undefined;\n }\n}\n"],"names":["NotEmptyRule","PropertyRule","propertyAccessor","isValid","value","undefined","trim","Array","isArray","length","NotNullRule"],"mappings":";;AAAA;AACA;AAIA;;;IAIO,MAAMA,YAAAA,SAAwBC,YAAAA,CAAAA;AACjC;;;QAIA,WAAA,CAAYC,gBAA0C,CAAE;AACpD,QAAA,KAAK,CAACA,gBAAAA,EAAkB,qCAAA,CAAA;AAC5B,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAc,EAAW;QACvC,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,EAAW;YACvC,OAAO,KAAA;AACX,QAAA;AACA,QAAA,IAAI,OAAOD,KAAAA,KAAU,QAAA,IAAYA,KAAAA,CAAME,IAAI,OAAO,EAAA,EAAI;YAClD,OAAO,KAAA;AACX,QAAA;AACA,QAAA,IAAIC,MAAMC,OAAO,CAACJ,UAAUA,KAAAA,CAAMK,MAAM,KAAK,CAAA,EAAG;YAC5C,OAAO,KAAA;AACX,QAAA;QACA,OAAO,IAAA;AACX,IAAA;AACJ;AAEA;;;IAIO,MAAMC,WAAAA,SAAuBT,YAAAA,CAAAA;AAChC;;;QAIA,WAAA,CAAYC,gBAA0C,CAAE;AACpD,QAAA,KAAK,CAACA,gBAAAA,EAAkB,qCAAA,CAAA;AAC5B,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAc,EAAW;QACvC,OAAOA,KAAAA,KAAU,QAAQA,KAAAA,KAAUC,SAAAA;AACvC,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PhoneRule.js","sources":["../../../../validation/rules/PhoneRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a string matches a phone number pattern.\n * @template T The type being validated.\n */\nexport class PhoneRule<T> extends PropertyRule<T, string> {\n private static readonly phoneRegex = /^[\\d\\s()+-]+$/;\n\n /**\n * Initializes a new instance of the {@link PhoneRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n */\n constructor(propertyAccessor: (instance: T) => string) {\n super(propertyAccessor, \"'{PropertyName}' is not a valid phone number.\");\n }\n\n /** @inheritdoc */\n protected isValid(value: string): boolean {\n if (value === null || value === undefined || value === '') {\n return true; // Use NotNull/NotEmpty for null checks\n }\n return PhoneRule.phoneRegex.test(value);\n }\n}\n"],"names":["PhoneRule","PropertyRule","phoneRegex","propertyAccessor","isValid","value","undefined","test"],"mappings":";;AAAA;AACA;AAIA;;;IAIO,MAAMA,SAAAA,SAAqBC,YAAAA,CAAAA;AAC9B,IAAA,OAAwBC,aAAa,eAAA;AAErC;;;QAIA,WAAA,CAAYC,gBAAyC,CAAE;AACnD,QAAA,KAAK,CAACA,gBAAAA,EAAkB,+CAAA,CAAA;AAC5B,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;AACtC,QAAA,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,IAAaD,UAAU,EAAA,EAAI;AACvD,YAAA,OAAO;AACX,QAAA;AACA,QAAA,OAAOL,SAAAA,CAAUE,UAAU,CAACK,IAAI,CAACF,KAAAA,CAAAA;AACrC,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"PhoneRule.js","sources":["../../../../validation/rules/PhoneRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a string matches a phone number pattern.\n * @template T The type being validated.\n */\nexport class PhoneRule<T> extends PropertyRule<T, string> {\n private static readonly phoneRegex = /^[\\d\\s()+-]+$/;\n\n /**\n * Initializes a new instance of the {@link PhoneRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n */\n constructor(propertyAccessor: (instance: T) => string) {\n super(propertyAccessor, \"'{PropertyName}' is not a valid phone number.\");\n }\n\n /** @inheritdoc */\n protected isValid(value: string): boolean {\n if (value === null || value === undefined || value === '') {\n return true; // Use NotNull/NotEmpty for null checks\n }\n return PhoneRule.phoneRegex.test(value);\n }\n}\n"],"names":["PhoneRule","PropertyRule","phoneRegex","propertyAccessor","isValid","value","undefined","test"],"mappings":";;AAAA;AACA;AAIA;;;IAIO,MAAMA,SAAAA,SAAqBC,YAAAA,CAAAA;AAC9B,IAAA,OAAwBC,aAAa,eAAA;AAErC;;;QAIA,WAAA,CAAYC,gBAAyC,CAAE;AACnD,QAAA,KAAK,CAACA,gBAAAA,EAAkB,+CAAA,CAAA;AAC5B,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;AACtC,QAAA,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,IAAaD,UAAU,EAAA,EAAI;AACvD,YAAA,OAAO;AACX,QAAA;AACA,QAAA,OAAOL,SAAAA,CAAUE,UAAU,CAACK,IAAI,CAACF,KAAAA,CAAAA;AACrC,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegexRule.js","sources":["../../../../validation/rules/RegexRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a value matches a regular expression.\n * @template T The type being validated.\n */\nexport class RegexRule<T> extends PropertyRule<T, string> {\n /**\n * Initializes a new instance of the {@link RegexRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param pattern The regular expression pattern to match.\n * @param errorMessage Optional error message.\n */\n constructor(propertyAccessor: (instance: T) => string, private readonly pattern: RegExp, errorMessage?: string) {\n super(propertyAccessor, errorMessage || \"'{PropertyName}' is not in the correct format.\");\n }\n\n /** @inheritdoc */\n protected isValid(value: string): boolean {\n if (value === null || value === undefined || value === '') {\n return true; // Use NotNull/NotEmpty for null checks\n }\n return this.pattern.test(value);\n }\n}\n"],"names":["RegexRule","PropertyRule","propertyAccessor","errorMessage","pattern","isValid","value","undefined","test"],"mappings":";;AAAA;AACA;AAIA;;;IAIO,MAAMA,SAAAA,SAAqBC,YAAAA,CAAAA;;AAC9B;;;;;AAKC,QACD,YAAYC,gBAAyC,EAAE,OAAgC,EAAEC,YAAqB,CAAE;AAC5G,QAAA,KAAK,CAACD,gBAAAA,EAAkBC,YAAAA,IAAgB,gDAAA,CAAA,EAAA,IAAA,CAD4BC,OAAAA,GAAAA,OAAAA;AAExE,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;AACtC,QAAA,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,IAAaD,UAAU,EAAA,EAAI;AACvD,YAAA,OAAO;AACX,QAAA;AACA,QAAA,OAAO,IAAI,CAACF,OAAO,CAACI,IAAI,CAACF,KAAAA,CAAAA;AAC7B,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"RegexRule.js","sources":["../../../../validation/rules/RegexRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a value matches a regular expression.\n * @template T The type being validated.\n */\nexport class RegexRule<T> extends PropertyRule<T, string> {\n /**\n * Initializes a new instance of the {@link RegexRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n * @param pattern The regular expression pattern to match.\n * @param errorMessage Optional error message.\n */\n constructor(propertyAccessor: (instance: T) => string, private readonly pattern: RegExp, errorMessage?: string) {\n super(propertyAccessor, errorMessage || \"'{PropertyName}' is not in the correct format.\");\n }\n\n /** @inheritdoc */\n protected isValid(value: string): boolean {\n if (value === null || value === undefined || value === '') {\n return true; // Use NotNull/NotEmpty for null checks\n }\n return this.pattern.test(value);\n }\n}\n"],"names":["RegexRule","PropertyRule","propertyAccessor","errorMessage","pattern","isValid","value","undefined","test"],"mappings":";;AAAA;AACA;AAIA;;;IAIO,MAAMA,SAAAA,SAAqBC,YAAAA,CAAAA;;AAC9B;;;;;AAKC,QACD,YAAYC,gBAAyC,EAAE,OAAgC,EAAEC,YAAqB,CAAE;AAC5G,QAAA,KAAK,CAACD,gBAAAA,EAAkBC,YAAAA,IAAgB,gDAAA,CAAA,EAAA,IAAA,CAD4BC,OAAAA,GAAAA,OAAAA;AAExE,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;AACtC,QAAA,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,IAAaD,UAAU,EAAA,EAAI;AACvD,YAAA,OAAO;AACX,QAAA;AACA,QAAA,OAAO,IAAI,CAACF,OAAO,CAACI,IAAI,CAACF,KAAAA,CAAAA;AAC7B,IAAA;AACJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlRule.js","sources":["../../../../validation/rules/UrlRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a string is a valid URL.\n * @template T The type being validated.\n */\nexport class UrlRule<T> extends PropertyRule<T, string> {\n private static readonly urlRegex = /^https?:\\/\\/.+/i;\n\n /**\n * Initializes a new instance of the {@link UrlRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n */\n constructor(propertyAccessor: (instance: T) => string) {\n super(propertyAccessor, \"'{PropertyName}' is not a valid URL.\");\n }\n\n /** @inheritdoc */\n protected isValid(value: string): boolean {\n if (value === null || value === undefined || value === '') {\n return true; // Use NotNull/NotEmpty for null checks\n }\n return UrlRule.urlRegex.test(value);\n }\n}\n"],"names":["UrlRule","PropertyRule","urlRegex","propertyAccessor","isValid","value","undefined","test"],"mappings":";;AAAA;AACA;AAIA;;;IAIO,MAAMA,OAAAA,SAAmBC,YAAAA,CAAAA;AAC5B,IAAA,OAAwBC,WAAW,iBAAA;AAEnC;;;QAIA,WAAA,CAAYC,gBAAyC,CAAE;AACnD,QAAA,KAAK,CAACA,gBAAAA,EAAkB,sCAAA,CAAA;AAC5B,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;AACtC,QAAA,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,IAAaD,UAAU,EAAA,EAAI;AACvD,YAAA,OAAO;AACX,QAAA;AACA,QAAA,OAAOL,OAAAA,CAAQE,QAAQ,CAACK,IAAI,CAACF,KAAAA,CAAAA;AACjC,IAAA;AACJ
|
|
1
|
+
{"version":3,"file":"UrlRule.js","sources":["../../../../validation/rules/UrlRule.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyRule } from '../PropertyRule';\n\n/**\n * Validation rule that checks if a string is a valid URL.\n * @template T The type being validated.\n */\nexport class UrlRule<T> extends PropertyRule<T, string> {\n private static readonly urlRegex = /^https?:\\/\\/.+/i;\n\n /**\n * Initializes a new instance of the {@link UrlRule} class.\n * @param propertyAccessor Function to access the property value from the instance.\n */\n constructor(propertyAccessor: (instance: T) => string) {\n super(propertyAccessor, \"'{PropertyName}' is not a valid URL.\");\n }\n\n /** @inheritdoc */\n protected isValid(value: string): boolean {\n if (value === null || value === undefined || value === '') {\n return true; // Use NotNull/NotEmpty for null checks\n }\n return UrlRule.urlRegex.test(value);\n }\n}\n"],"names":["UrlRule","PropertyRule","urlRegex","propertyAccessor","isValid","value","undefined","test"],"mappings":";;AAAA;AACA;AAIA;;;IAIO,MAAMA,OAAAA,SAAmBC,YAAAA,CAAAA;AAC5B,IAAA,OAAwBC,WAAW,iBAAA;AAEnC;;;QAIA,WAAA,CAAYC,gBAAyC,CAAE;AACnD,QAAA,KAAK,CAACA,gBAAAA,EAAkB,sCAAA,CAAA;AAC5B,IAAA;AAEA,uBACUC,OAAAA,CAAQC,KAAa,EAAW;AACtC,QAAA,IAAIA,KAAAA,KAAU,IAAA,IAAQA,KAAAA,KAAUC,SAAAA,IAAaD,UAAU,EAAA,EAAI;AACvD,YAAA,OAAO;AACX,QAAA;AACA,QAAA,OAAOL,OAAAA,CAAQE,QAAQ,CAACK,IAAI,CAACF,KAAAA,CAAAA;AACjC,IAAA;AACJ;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cratis/arc",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.14.0",
|
|
4
4
|
"description": "TypeScript command, query, validation, identity, and messaging runtime for Cratis Arc — the CQRS application framework for ASP.NET Core — used by generated proxies.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cratis",
|
|
@@ -82,10 +82,10 @@
|
|
|
82
82
|
"up": "yarn g:up"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@cratis/fundamentals": "^7.
|
|
85
|
+
"@cratis/fundamentals": "^7.19.2",
|
|
86
86
|
"rxjs": "^7.8.2"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@cratis/fundamentals": "7.
|
|
89
|
+
"@cratis/fundamentals": "7.19.2"
|
|
90
90
|
}
|
|
91
91
|
}
|