Comparing version 1.0.0-alpha.0 to 1.0.0-alpha.1
@@ -0,1 +1,2 @@ | ||
export * from './async-max-work-interval-msec'; | ||
export * from './async-time-complexity-threshold'; | ||
@@ -2,0 +3,0 @@ export * from './logging'; |
@@ -17,2 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./async-max-work-interval-msec"), exports); | ||
__exportStar(require("./async-time-complexity-threshold"), exports); | ||
@@ -19,0 +20,0 @@ __exportStar(require("./logging"), exports); |
@@ -5,6 +5,6 @@ import type { Schema } from '../../types/schema'; | ||
schemaType: 'boolean'; | ||
oneOf: ValueT[]; | ||
allowedValues: ValueT[]; | ||
} | ||
/** Requires a boolean. If one or more values are specified, the boolean must also match one of the specified values. */ | ||
export declare const boolean: <ValueT extends boolean>(...oneOf: ValueT[]) => BooleanSchema<ValueT>; | ||
export declare const boolean: <ValueT extends boolean>(...allowedValues: ValueT[]) => BooleanSchema<ValueT>; | ||
//# sourceMappingURL=boolean.d.ts.map |
@@ -10,4 +10,4 @@ "use strict"; | ||
/** Requires a boolean. If one or more values are specified, the boolean must also match one of the specified values. */ | ||
const boolean = (...oneOf) => { | ||
const equalsSet = new Set(oneOf); | ||
const boolean = (...allowedValues) => { | ||
const equalsSet = new Set(allowedValues); | ||
const internalValidate = (value, validatorOptions, path) => { | ||
@@ -20,3 +20,3 @@ if (typeof value !== 'boolean') { | ||
} | ||
if (oneOf.length > 0) { | ||
if (allowedValues.length > 0) { | ||
return (0, validate_value_1.validateValue)(value, { allowed: equalsSet, path }); | ||
@@ -29,3 +29,3 @@ } | ||
schemaType: 'boolean', | ||
oneOf, | ||
allowedValues, | ||
estimatedValidationTimeComplexity: 1, | ||
@@ -32,0 +32,0 @@ usesCustomSerDes: false |
@@ -7,6 +7,6 @@ import { Range } from '../../types/range'; | ||
/** If one or more values are specified, the value must be equal to one of the specified values or in one of the specified ranges */ | ||
oneOf?: Array<Range<Date>>; | ||
allowedRanges?: Array<Range<Date>>; | ||
} | ||
/** Requires a `Date`, which will be serialized as an ISO Date/Time string */ | ||
export declare const date: (oneOf?: Array<Range<Date>>) => DateSchema; | ||
export declare const date: (allowedRanges?: Array<Range<Date>>) => DateSchema; | ||
//# sourceMappingURL=date.d.ts.map |
@@ -16,3 +16,3 @@ "use strict"; | ||
/** Requires a `Date`, which will be serialized as an ISO Date/Time string */ | ||
const date = (oneOf = []) => { | ||
const date = (allowedRanges = []) => { | ||
const validateDeserializedForm = (value, validatorOptions, path) => { | ||
@@ -22,4 +22,4 @@ if (validatorOptions.validation === 'none') { | ||
} | ||
if (oneOf.length > 0) { | ||
const rangeResult = (0, validate_value_in_range_1.validateValueInRange)(value, { allowed: oneOf, path }); | ||
if (allowedRanges.length > 0) { | ||
const rangeResult = (0, validate_value_in_range_1.validateValueInRange)(value, { allowed: allowedRanges, path }); | ||
if (rangeResult.error !== undefined) { | ||
@@ -26,0 +26,0 @@ return rangeResult; |
@@ -5,6 +5,6 @@ import type { Schema } from '../../types/schema'; | ||
schemaType: 'number'; | ||
oneOf: ValueT[]; | ||
allowedValues: ValueT[]; | ||
} | ||
/** Requires a real, finite number. If one or more values are specified, the value must also be equal to one of the specified values */ | ||
export declare const number: <ValueT extends number>(...oneOf: ValueT[]) => NumberSchema<ValueT>; | ||
export declare const number: <ValueT extends number>(...allowedValues: ValueT[]) => NumberSchema<ValueT>; | ||
//# sourceMappingURL=number.d.ts.map |
@@ -10,4 +10,4 @@ "use strict"; | ||
/** Requires a real, finite number. If one or more values are specified, the value must also be equal to one of the specified values */ | ||
const number = (...oneOf) => { | ||
const equalsNumbers = oneOf.filter((v) => typeof v === 'number'); | ||
const number = (...allowedValues) => { | ||
const equalsNumbers = allowedValues.filter((v) => typeof v === 'number'); | ||
const equalsNumbersSet = new Set(equalsNumbers); | ||
@@ -38,4 +38,4 @@ const internalValidate = (value, validatorOptions, path) => { | ||
schemaType: 'number', | ||
oneOf, | ||
estimatedValidationTimeComplexity: oneOf.length + 1, | ||
allowedValues, | ||
estimatedValidationTimeComplexity: allowedValues.length + 1, | ||
usesCustomSerDes: false | ||
@@ -42,0 +42,0 @@ }, { internalValidate }); |
@@ -13,3 +13,3 @@ import type { Range } from '../../types/range'; | ||
/** If one or more values are specified, the value must be equal to one of the specified values or in one of the specified ranges */ | ||
oneOf?: Array<number | Range<number>>; | ||
allowedValuesAndRanges?: Array<number | Range<number>>; | ||
} | ||
@@ -19,3 +19,3 @@ /** Requires a real, finite number. If one or more values and/or ranges are specified, the value must also be equal to one of the specified | ||
* specified divisors. */ | ||
export declare const restrictedNumber: (oneOf: Array<number | Range<number>>, { divisibleBy, ...options }?: RestrictedNumberOptions) => RestrictedNumberSchema; | ||
export declare const restrictedNumber: (allowedValuesAndRanges: Array<number | Range<number>>, { divisibleBy, ...options }?: RestrictedNumberOptions) => RestrictedNumberSchema; | ||
//# sourceMappingURL=restricted-number.d.ts.map |
@@ -24,7 +24,7 @@ "use strict"; | ||
* specified divisors. */ | ||
const restrictedNumber = (oneOf, _a = {}) => { | ||
const restrictedNumber = (allowedValuesAndRanges, _a = {}) => { | ||
var { divisibleBy = [] } = _a, options = __rest(_a, ["divisibleBy"]); | ||
const oneOfNumbers = oneOf.filter((v) => typeof v === 'number'); | ||
const oneOfRanges = oneOf.filter((v) => typeof v !== 'number'); | ||
const oneOfNumbersSet = new Set(oneOfNumbers); | ||
const allowedNumbers = allowedValuesAndRanges.filter((v) => typeof v === 'number'); | ||
const allowedRanges = allowedValuesAndRanges.filter((v) => typeof v !== 'number'); | ||
const allowedNumbersSet = new Set(allowedNumbers); | ||
const internalValidate = (value, validatorOptions, path) => { | ||
@@ -43,7 +43,7 @@ if (typeof value !== 'number') { | ||
} | ||
if (oneOfNumbers.length > 0) { | ||
const valueResult = (0, validate_value_1.validateValue)(value, { allowed: oneOfNumbersSet, path }); | ||
if (allowedNumbers.length > 0) { | ||
const valueResult = (0, validate_value_1.validateValue)(value, { allowed: allowedNumbersSet, path }); | ||
if (valueResult.error !== undefined) { | ||
if (oneOfRanges.length > 0) { | ||
const rangeResult = (0, validate_value_in_range_1.validateValueInRange)(value, { allowed: oneOfRanges, path }); | ||
if (allowedRanges.length > 0) { | ||
const rangeResult = (0, validate_value_in_range_1.validateValueInRange)(value, { allowed: allowedRanges, path }); | ||
if (rangeResult.error !== undefined) { | ||
@@ -58,4 +58,4 @@ return rangeResult; | ||
} | ||
else if (oneOfRanges.length > 0) { | ||
const rangeResult = (0, validate_value_in_range_1.validateValueInRange)(value, { allowed: oneOfRanges, path }); | ||
else if (allowedRanges.length > 0) { | ||
const rangeResult = (0, validate_value_in_range_1.validateValueInRange)(value, { allowed: allowedRanges, path }); | ||
if (rangeResult.error !== undefined) { | ||
@@ -70,4 +70,4 @@ return rangeResult; | ||
}; | ||
return (0, internal_schema_maker_1.makeInternalSchema)(Object.assign(Object.assign({ valueType: undefined, schemaType: 'restricted-number', oneOf, | ||
divisibleBy }, options), { estimatedValidationTimeComplexity: oneOfRanges.length + 1, usesCustomSerDes: false }), { internalValidate }); | ||
return (0, internal_schema_maker_1.makeInternalSchema)(Object.assign(Object.assign({ valueType: undefined, schemaType: 'restricted-number', allowedValuesAndRanges, | ||
divisibleBy }, options), { estimatedValidationTimeComplexity: allowedRanges.length + 1, usesCustomSerDes: false }), { internalValidate }); | ||
}; | ||
@@ -74,0 +74,0 @@ exports.restrictedNumber = restrictedNumber; |
@@ -10,3 +10,3 @@ import type { Schema } from '../../types/schema'; | ||
schemaType: 'string'; | ||
oneOf: ValueT[]; | ||
allowedValues: ValueT[]; | ||
allowEmptyString: () => AllowEmptyStringSchema<ValueT>; | ||
@@ -19,3 +19,3 @@ } | ||
*/ | ||
export declare const string: <ValueT extends string>(...oneOf: ValueT[]) => StringSchema<ValueT>; | ||
export declare const string: <ValueT extends string>(...allowedValues: ValueT[]) => StringSchema<ValueT>; | ||
//# sourceMappingURL=string.d.ts.map |
@@ -14,4 +14,4 @@ "use strict"; | ||
*/ | ||
const string = (...oneOf) => { | ||
const equalsSet = new Set(oneOf); | ||
const string = (...allowedValues) => { | ||
const equalsSet = new Set(allowedValues); | ||
const internalValidate = (value, validatorOptions, path) => { | ||
@@ -24,3 +24,3 @@ if (typeof value !== 'string') { | ||
} | ||
if (oneOf.length > 0) { | ||
if (allowedValues.length > 0) { | ||
return (0, validate_value_1.validateValue)(value, { allowed: equalsSet, path }); | ||
@@ -36,4 +36,4 @@ } | ||
schemaType: 'string', | ||
oneOf, | ||
estimatedValidationTimeComplexity: oneOf.length + 1, | ||
allowedValues, | ||
estimatedValidationTimeComplexity: allowedValues.length + 1, | ||
usesCustomSerDes: false | ||
@@ -40,0 +40,0 @@ }, { internalValidate })), { allowEmptyString: () => allowEmptyString(fullStringSchema) }); |
export * from './get-meaningful-typeof'; | ||
export * from './make-number-subtype-array'; | ||
export * from './make-string-subtype-array'; | ||
//# sourceMappingURL=exports.d.ts.map |
@@ -18,3 +18,4 @@ "use strict"; | ||
__exportStar(require("./get-meaningful-typeof"), exports); | ||
__exportStar(require("./make-number-subtype-array"), exports); | ||
__exportStar(require("./make-string-subtype-array"), exports); | ||
//# sourceMappingURL=exports.js.map |
@@ -48,5 +48,2 @@ "use strict"; | ||
} | ||
else { | ||
output.push(...Object.keys(arg)); | ||
} | ||
} | ||
@@ -53,0 +50,0 @@ return output; |
{ | ||
"name": "yaschema", | ||
"version": "1.0.0-alpha.0", | ||
"version": "1.0.0-alpha.1", | ||
"description": "Yet another schema", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -22,2 +22,4 @@ # yaschema | ||
[Try it Out – CodeSandbox](https://codesandbox.io/s/agitated-lucy-bxog45) | ||
```typescript | ||
@@ -233,2 +235,4 @@ import { schema } from 'yaschema'; | ||
Be sure to check out our other [Open Source @ Passfolio](https://github.com/Passfolio) projects as well. | ||
<!-- Definitions --> | ||
@@ -235,0 +239,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
284634
3111
245