@astral/validations 4.20.3 → 4.21.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/node/any/any.d.ts +23 -0
- package/node/any/any.js +29 -0
- package/node/any/index.d.ts +1 -0
- package/node/any/index.js +17 -0
- package/node/array/array.d.ts +15 -0
- package/node/array/array.js +25 -0
- package/node/array/constants.d.ts +2 -0
- package/node/array/constants.js +8 -0
- package/node/array/index.d.ts +2 -0
- package/node/array/index.js +18 -0
- package/node/arrayItem/arrayItem.d.ts +27 -0
- package/node/arrayItem/arrayItem.js +37 -0
- package/node/arrayItem/index.d.ts +1 -0
- package/node/arrayItem/index.js +17 -0
- package/node/boolean/boolean.d.ts +13 -0
- package/node/boolean/boolean.js +23 -0
- package/node/boolean/constants.d.ts +2 -0
- package/node/boolean/constants.js +8 -0
- package/node/boolean/index.d.ts +2 -0
- package/node/boolean/index.js +18 -0
- package/node/containsDifferentCases/constants.d.ts +2 -0
- package/node/containsDifferentCases/constants.js +5 -0
- package/node/containsDifferentCases/containsDifferentCases.d.ts +16 -0
- package/node/containsDifferentCases/containsDifferentCases.js +26 -0
- package/node/containsDifferentCases/index.d.ts +2 -0
- package/node/containsDifferentCases/index.js +18 -0
- package/node/containsNumbers/constants.d.ts +2 -0
- package/node/containsNumbers/constants.js +5 -0
- package/node/containsNumbers/containsNumbers.d.ts +16 -0
- package/node/containsNumbers/containsNumbers.js +24 -0
- package/node/containsNumbers/index.d.ts +2 -0
- package/node/containsNumbers/index.js +18 -0
- package/node/containsPunctuationMarks/constants.d.ts +2 -0
- package/node/containsPunctuationMarks/constants.js +5 -0
- package/node/containsPunctuationMarks/containsPunctuationMarks.d.ts +16 -0
- package/node/containsPunctuationMarks/containsPunctuationMarks.js +24 -0
- package/node/containsPunctuationMarks/index.d.ts +2 -0
- package/node/containsPunctuationMarks/index.js +18 -0
- package/node/core/compose/compose.d.ts +6 -0
- package/node/core/compose/compose.js +11 -0
- package/node/core/compose/index.d.ts +1 -0
- package/node/core/compose/index.js +17 -0
- package/node/core/composeAsync/composeAsync.d.ts +6 -0
- package/node/core/composeAsync/composeAsync.js +28 -0
- package/node/core/composeAsync/index.d.ts +1 -0
- package/node/core/composeAsync/index.js +17 -0
- package/node/core/context/createContext/createContext.d.ts +19 -0
- package/node/core/context/createContext/createContext.js +25 -0
- package/node/core/context/createContext/index.d.ts +1 -0
- package/node/core/context/createContext/index.js +17 -0
- package/node/core/context/index.d.ts +2 -0
- package/node/core/context/index.js +18 -0
- package/node/core/context/types.d.ts +37 -0
- package/node/core/context/types.js +2 -0
- package/node/core/errors/ArrayError/ArrayError.d.ts +18 -0
- package/node/core/errors/ArrayError/ArrayError.js +14 -0
- package/node/core/errors/ArrayError/createArrayError/createArrayError.d.ts +5 -0
- package/node/core/errors/ArrayError/createArrayError/createArrayError.js +15 -0
- package/node/core/errors/ArrayError/createArrayError/index.d.ts +1 -0
- package/node/core/errors/ArrayError/createArrayError/index.js +17 -0
- package/node/core/errors/ArrayError/index.d.ts +2 -0
- package/node/core/errors/ArrayError/index.js +18 -0
- package/node/core/errors/ErrorMap/ErrorMap.d.ts +21 -0
- package/node/core/errors/ErrorMap/ErrorMap.js +14 -0
- package/node/core/errors/ErrorMap/createErrorMap/createErrorMap.d.ts +5 -0
- package/node/core/errors/ErrorMap/createErrorMap/createErrorMap.js +14 -0
- package/node/core/errors/ErrorMap/createErrorMap/index.d.ts +1 -0
- package/node/core/errors/ErrorMap/createErrorMap/index.js +17 -0
- package/node/core/errors/ErrorMap/index.d.ts +2 -0
- package/node/core/errors/ErrorMap/index.js +18 -0
- package/node/core/errors/SimpleError/SimpleError.d.ts +16 -0
- package/node/core/errors/SimpleError/SimpleError.js +13 -0
- package/node/core/errors/SimpleError/createSimpleError/createSimpleError.d.ts +6 -0
- package/node/core/errors/SimpleError/createSimpleError/createSimpleError.js +9 -0
- package/node/core/errors/SimpleError/createSimpleError/index.d.ts +1 -0
- package/node/core/errors/SimpleError/createSimpleError/index.js +17 -0
- package/node/core/errors/SimpleError/index.d.ts +2 -0
- package/node/core/errors/SimpleError/index.js +18 -0
- package/node/core/errors/constants.d.ts +2 -0
- package/node/core/errors/constants.js +8 -0
- package/node/core/errors/createErrorCode/createErrorCode.d.ts +5 -0
- package/node/core/errors/createErrorCode/createErrorCode.js +8 -0
- package/node/core/errors/createErrorCode/index.d.ts +1 -0
- package/node/core/errors/createErrorCode/index.js +17 -0
- package/node/core/errors/index.d.ts +6 -0
- package/node/core/errors/index.js +22 -0
- package/node/core/errors/types.d.ts +18 -0
- package/node/core/errors/types.js +2 -0
- package/node/core/guard/createGuard/createGuard.d.ts +71 -0
- package/node/core/guard/createGuard/createGuard.js +28 -0
- package/node/core/guard/createGuard/index.d.ts +1 -0
- package/node/core/guard/createGuard/index.js +17 -0
- package/node/core/guard/index.d.ts +1 -0
- package/node/core/guard/index.js +17 -0
- package/node/core/index.d.ts +9 -0
- package/node/core/index.js +25 -0
- package/node/core/logger/index.d.ts +1 -0
- package/node/core/logger/index.js +17 -0
- package/node/core/logger/logger.d.ts +6 -0
- package/node/core/logger/logger.js +12 -0
- package/node/core/rule/callAsyncRule/callAsyncRule.d.ts +8 -0
- package/node/core/rule/callAsyncRule/callAsyncRule.js +29 -0
- package/node/core/rule/callAsyncRule/index.d.ts +1 -0
- package/node/core/rule/callAsyncRule/index.js +17 -0
- package/node/core/rule/callRule/callRule.d.ts +7 -0
- package/node/core/rule/callRule/callRule.js +13 -0
- package/node/core/rule/callRule/index.d.ts +1 -0
- package/node/core/rule/callRule/index.js +17 -0
- package/node/core/rule/createRule/createRule.d.ts +34 -0
- package/node/core/rule/createRule/createRule.js +31 -0
- package/node/core/rule/createRule/index.d.ts +1 -0
- package/node/core/rule/createRule/index.js +17 -0
- package/node/core/rule/index.d.ts +5 -0
- package/node/core/rule/index.js +21 -0
- package/node/core/rule/required/constants.d.ts +2 -0
- package/node/core/rule/required/constants.js +8 -0
- package/node/core/rule/required/index.d.ts +2 -0
- package/node/core/rule/required/index.js +18 -0
- package/node/core/rule/required/required.d.ts +11 -0
- package/node/core/rule/required/required.js +29 -0
- package/node/core/rule/types.d.ts +23 -0
- package/node/core/rule/types.js +2 -0
- package/node/core/types.d.ts +9 -0
- package/node/core/types.js +2 -0
- package/node/core/utils/index.d.ts +8 -0
- package/node/core/utils/index.js +24 -0
- package/node/core/utils/isDateEarlier/index.d.ts +1 -0
- package/node/core/utils/isDateEarlier/index.js +17 -0
- package/node/core/utils/isDateEarlier/isDateEarlier.d.ts +1 -0
- package/node/core/utils/isDateEarlier/isDateEarlier.js +8 -0
- package/node/core/utils/isFullNameValidCharacters/index.d.ts +1 -0
- package/node/core/utils/isFullNameValidCharacters/index.js +17 -0
- package/node/core/utils/isFullNameValidCharacters/isFullNameValidCharacters.d.ts +5 -0
- package/node/core/utils/isFullNameValidCharacters/isFullNameValidCharacters.js +9 -0
- package/node/core/utils/isHasConsecutiveChars/index.d.ts +1 -0
- package/node/core/utils/isHasConsecutiveChars/index.js +17 -0
- package/node/core/utils/isHasConsecutiveChars/isHasConsecutiveChars.d.ts +4 -0
- package/node/core/utils/isHasConsecutiveChars/isHasConsecutiveChars.js +8 -0
- package/node/core/utils/isNoDoubleZeroStart/index.d.ts +1 -0
- package/node/core/utils/isNoDoubleZeroStart/index.js +17 -0
- package/node/core/utils/isNoDoubleZeroStart/isNoDoubleZeroStart.d.ts +4 -0
- package/node/core/utils/isNoDoubleZeroStart/isNoDoubleZeroStart.js +8 -0
- package/node/core/utils/isStartsWithAndEndsWithLetter/index.d.ts +1 -0
- package/node/core/utils/isStartsWithAndEndsWithLetter/index.js +17 -0
- package/node/core/utils/isStartsWithAndEndsWithLetter/isStartsWithAndEndsWithLetter.d.ts +4 -0
- package/node/core/utils/isStartsWithAndEndsWithLetter/isStartsWithAndEndsWithLetter.js +8 -0
- package/node/core/utils/isStringOfZeros/index.d.ts +1 -0
- package/node/core/utils/isStringOfZeros/index.js +17 -0
- package/node/core/utils/isStringOfZeros/isStringOfZeros.d.ts +4 -0
- package/node/core/utils/isStringOfZeros/isStringOfZeros.js +13 -0
- package/node/core/utils/isValidFullNameLength/index.d.ts +1 -0
- package/node/core/utils/isValidFullNameLength/index.js +17 -0
- package/node/core/utils/isValidFullNameLength/isValidFullNameLength.d.ts +4 -0
- package/node/core/utils/isValidFullNameLength/isValidFullNameLength.js +8 -0
- package/node/core/utils/resetTime/index.d.ts +1 -0
- package/node/core/utils/resetTime/index.js +17 -0
- package/node/core/utils/resetTime/resetTime.d.ts +5 -0
- package/node/core/utils/resetTime/resetTime.js +16 -0
- package/node/date/constants.d.ts +3 -0
- package/node/date/constants.js +12 -0
- package/node/date/date.d.ts +19 -0
- package/node/date/date.js +28 -0
- package/node/date/index.d.ts +2 -0
- package/node/date/index.js +18 -0
- package/node/deepPartial/deepPartial.d.ts +21 -0
- package/node/deepPartial/deepPartial.js +25 -0
- package/node/deepPartial/index.d.ts +1 -0
- package/node/deepPartial/index.js +17 -0
- package/node/email/constants.d.ts +10 -0
- package/node/email/constants.js +22 -0
- package/node/email/email.d.ts +30 -0
- package/node/email/email.js +59 -0
- package/node/email/index.d.ts +2 -0
- package/node/email/index.js +18 -0
- package/node/enabled/enabled.d.ts +34 -0
- package/node/enabled/enabled.js +35 -0
- package/node/enabled/index.d.ts +1 -0
- package/node/enabled/index.js +17 -0
- package/node/guid/constants.d.ts +3 -0
- package/node/guid/constants.js +9 -0
- package/node/guid/guid.d.ts +16 -0
- package/node/guid/guid.js +20 -0
- package/node/guid/index.d.ts +2 -0
- package/node/guid/index.js +18 -0
- package/node/index.d.ts +53 -0
- package/node/index.js +185 -0
- package/node/innFL/constants.d.ts +2 -0
- package/node/innFL/constants.js +8 -0
- package/node/innFL/index.d.ts +2 -0
- package/node/innFL/index.js +18 -0
- package/node/innFL/innFL.d.ts +17 -0
- package/node/innFL/innFL.js +25 -0
- package/node/innIP/constants.d.ts +2 -0
- package/node/innIP/constants.js +8 -0
- package/node/innIP/index.d.ts +2 -0
- package/node/innIP/index.js +18 -0
- package/node/innIP/innIP.d.ts +17 -0
- package/node/innIP/innIP.js +31 -0
- package/node/innTwelveSymbols/constants.d.ts +5 -0
- package/node/innTwelveSymbols/constants.js +13 -0
- package/node/innTwelveSymbols/index.d.ts +2 -0
- package/node/innTwelveSymbols/index.js +18 -0
- package/node/innTwelveSymbols/innTwelveSymbols.d.ts +17 -0
- package/node/innTwelveSymbols/innTwelveSymbols.js +41 -0
- package/node/innUL/constants.d.ts +4 -0
- package/node/innUL/constants.js +10 -0
- package/node/innUL/index.d.ts +2 -0
- package/node/innUL/index.js +18 -0
- package/node/innUL/innUL.d.ts +17 -0
- package/node/innUL/innUL.js +43 -0
- package/node/integer/constants.d.ts +2 -0
- package/node/integer/constants.js +8 -0
- package/node/integer/index.d.ts +2 -0
- package/node/integer/index.js +18 -0
- package/node/integer/integer.d.ts +25 -0
- package/node/integer/integer.js +32 -0
- package/node/kpp/constants.d.ts +5 -0
- package/node/kpp/constants.js +17 -0
- package/node/kpp/index.d.ts +2 -0
- package/node/kpp/index.js +18 -0
- package/node/kpp/kpp.d.ts +17 -0
- package/node/kpp/kpp.js +30 -0
- package/node/length/constants.d.ts +2 -0
- package/node/length/constants.js +5 -0
- package/node/length/index.d.ts +2 -0
- package/node/length/index.js +18 -0
- package/node/length/length.d.ts +22 -0
- package/node/length/length.js +30 -0
- package/node/max/constants.d.ts +5 -0
- package/node/max/constants.js +8 -0
- package/node/max/index.d.ts +2 -0
- package/node/max/index.js +18 -0
- package/node/max/max.d.ts +26 -0
- package/node/max/max.js +46 -0
- package/node/min/constants.d.ts +5 -0
- package/node/min/constants.js +8 -0
- package/node/min/index.d.ts +2 -0
- package/node/min/index.js +18 -0
- package/node/min/min.d.ts +26 -0
- package/node/min/min.js +46 -0
- package/node/minYearsOld/constants.d.ts +4 -0
- package/node/minYearsOld/constants.js +7 -0
- package/node/minYearsOld/index.d.ts +2 -0
- package/node/minYearsOld/index.js +18 -0
- package/node/minYearsOld/minYearsOld.d.ts +24 -0
- package/node/minYearsOld/minYearsOld.js +48 -0
- package/node/mobilePhone/constants.d.ts +3 -0
- package/node/mobilePhone/constants.js +9 -0
- package/node/mobilePhone/index.d.ts +2 -0
- package/node/mobilePhone/index.js +18 -0
- package/node/mobilePhone/mobilePhone.d.ts +19 -0
- package/node/mobilePhone/mobilePhone.js +25 -0
- package/node/number/constants.d.ts +4 -0
- package/node/number/constants.js +16 -0
- package/node/number/index.d.ts +2 -0
- package/node/number/index.js +18 -0
- package/node/number/number.d.ts +19 -0
- package/node/number/number.js +30 -0
- package/node/object/constants.d.ts +2 -0
- package/node/object/constants.js +8 -0
- package/node/object/index.d.ts +3 -0
- package/node/object/index.js +19 -0
- package/node/object/isEmptyErrors/index.d.ts +1 -0
- package/node/object/isEmptyErrors/index.js +17 -0
- package/node/object/isEmptyErrors/isEmptyErrors.d.ts +5 -0
- package/node/object/isEmptyErrors/isEmptyErrors.js +8 -0
- package/node/object/object.d.ts +49 -0
- package/node/object/object.js +54 -0
- package/node/object/objectAsync/index.d.ts +1 -0
- package/node/object/objectAsync/index.js +17 -0
- package/node/object/objectAsync/objectAsync.d.ts +61 -0
- package/node/object/objectAsync/objectAsync.js +76 -0
- package/node/ogrnIP/constants.d.ts +3 -0
- package/node/ogrnIP/constants.js +9 -0
- package/node/ogrnIP/index.d.ts +2 -0
- package/node/ogrnIP/index.js +18 -0
- package/node/ogrnIP/ogrnIP.d.ts +17 -0
- package/node/ogrnIP/ogrnIP.js +31 -0
- package/node/ogrnUL/constants.d.ts +3 -0
- package/node/ogrnUL/constants.js +9 -0
- package/node/ogrnUL/index.d.ts +2 -0
- package/node/ogrnUL/index.js +18 -0
- package/node/ogrnUL/ogrnUL.d.ts +17 -0
- package/node/ogrnUL/ogrnUL.js +31 -0
- package/node/onlyNumber/constants.d.ts +2 -0
- package/node/onlyNumber/constants.js +5 -0
- package/node/onlyNumber/index.d.ts +2 -0
- package/node/onlyNumber/index.js +18 -0
- package/node/onlyNumber/onlyNumber.d.ts +16 -0
- package/node/onlyNumber/onlyNumber.js +24 -0
- package/node/optional/index.d.ts +2 -0
- package/node/optional/index.js +18 -0
- package/node/optional/optional.d.ts +6 -0
- package/node/optional/optional.js +10 -0
- package/node/optional/optionalAsync/index.d.ts +1 -0
- package/node/optional/optionalAsync/index.js +17 -0
- package/node/optional/optionalAsync/optionalAsync.d.ts +6 -0
- package/node/optional/optionalAsync/optionalAsync.js +22 -0
- package/node/or/index.d.ts +1 -0
- package/node/or/index.js +17 -0
- package/node/or/or.d.ts +14 -0
- package/node/or/or.js +25 -0
- package/node/partial/index.d.ts +1 -0
- package/node/partial/index.js +17 -0
- package/node/partial/partial.d.ts +9 -0
- package/node/partial/partial.js +10 -0
- package/node/passportCode/constants.d.ts +4 -0
- package/node/passportCode/constants.js +16 -0
- package/node/passportCode/index.d.ts +2 -0
- package/node/passportCode/index.js +18 -0
- package/node/passportCode/passportCode.d.ts +17 -0
- package/node/passportCode/passportCode.js +42 -0
- package/node/passportNumber/constants.d.ts +4 -0
- package/node/passportNumber/constants.js +16 -0
- package/node/passportNumber/index.d.ts +2 -0
- package/node/passportNumber/index.js +18 -0
- package/node/passportNumber/passportNumber.d.ts +17 -0
- package/node/passportNumber/passportNumber.js +36 -0
- package/node/passportSeries/constants.d.ts +4 -0
- package/node/passportSeries/constants.js +16 -0
- package/node/passportSeries/index.d.ts +2 -0
- package/node/passportSeries/index.js +18 -0
- package/node/passportSeries/passportSeries.d.ts +17 -0
- package/node/passportSeries/passportSeries.js +36 -0
- package/node/pattern/constants.d.ts +2 -0
- package/node/pattern/constants.js +5 -0
- package/node/pattern/index.d.ts +2 -0
- package/node/pattern/index.js +18 -0
- package/node/pattern/pattern.d.ts +18 -0
- package/node/pattern/pattern.js +26 -0
- package/node/personName/constants.d.ts +2 -0
- package/node/personName/constants.js +8 -0
- package/node/personName/index.d.ts +2 -0
- package/node/personName/index.js +18 -0
- package/node/personName/personName.d.ts +17 -0
- package/node/personName/personName.js +33 -0
- package/node/personPatronymic/constants.d.ts +2 -0
- package/node/personPatronymic/constants.js +8 -0
- package/node/personPatronymic/index.d.ts +2 -0
- package/node/personPatronymic/index.js +18 -0
- package/node/personPatronymic/personPatronymic.d.ts +17 -0
- package/node/personPatronymic/personPatronymic.js +33 -0
- package/node/personSurname/constants.d.ts +2 -0
- package/node/personSurname/constants.js +8 -0
- package/node/personSurname/index.d.ts +2 -0
- package/node/personSurname/index.js +18 -0
- package/node/personSurname/personSurname.d.ts +17 -0
- package/node/personSurname/personSurname.js +33 -0
- package/node/positiveNumber/constants.d.ts +2 -0
- package/node/positiveNumber/constants.js +8 -0
- package/node/positiveNumber/index.d.ts +2 -0
- package/node/positiveNumber/index.js +18 -0
- package/node/positiveNumber/positiveNumber.d.ts +25 -0
- package/node/positiveNumber/positiveNumber.js +35 -0
- package/node/rangeDate/constants.d.ts +7 -0
- package/node/rangeDate/constants.js +28 -0
- package/node/rangeDate/index.d.ts +2 -0
- package/node/rangeDate/index.js +18 -0
- package/node/rangeDate/rangeDate.d.ts +50 -0
- package/node/rangeDate/rangeDate.js +69 -0
- package/node/rangeDateInterval/constants.d.ts +7 -0
- package/node/rangeDateInterval/constants.js +17 -0
- package/node/rangeDateInterval/index.d.ts +2 -0
- package/node/rangeDateInterval/index.js +18 -0
- package/node/rangeDateInterval/rangeDateInterval.d.ts +23 -0
- package/node/rangeDateInterval/rangeDateInterval.js +40 -0
- package/node/rangeDateInterval/types.d.ts +6 -0
- package/node/rangeDateInterval/types.js +2 -0
- package/node/rangeDateMinMax/constants.d.ts +8 -0
- package/node/rangeDateMinMax/constants.js +16 -0
- package/node/rangeDateMinMax/index.d.ts +2 -0
- package/node/rangeDateMinMax/index.js +18 -0
- package/node/rangeDateMinMax/rangeDateMinMax.d.ts +34 -0
- package/node/rangeDateMinMax/rangeDateMinMax.js +78 -0
- package/node/rangeDateMinMax/types.d.ts +2 -0
- package/node/rangeDateMinMax/types.js +2 -0
- package/node/rangeDateNotEqual/constants.d.ts +2 -0
- package/node/rangeDateNotEqual/constants.js +8 -0
- package/node/rangeDateNotEqual/index.d.ts +2 -0
- package/node/rangeDateNotEqual/index.js +18 -0
- package/node/rangeDateNotEqual/rangeDateNotEqual.d.ts +20 -0
- package/node/rangeDateNotEqual/rangeDateNotEqual.js +33 -0
- package/node/snils/constants.d.ts +4 -0
- package/node/snils/constants.js +10 -0
- package/node/snils/index.d.ts +2 -0
- package/node/snils/index.js +18 -0
- package/node/snils/snils.d.ts +17 -0
- package/node/snils/snils.js +68 -0
- package/node/string/constants.d.ts +2 -0
- package/node/string/constants.js +8 -0
- package/node/string/index.d.ts +3 -0
- package/node/string/index.js +19 -0
- package/node/string/string.d.ts +2 -0
- package/node/string/string.js +13 -0
- package/node/string/stringAsync/index.d.ts +1 -0
- package/node/string/stringAsync/index.js +17 -0
- package/node/string/stringAsync/stringAsync.d.ts +6 -0
- package/node/string/stringAsync/stringAsync.js +27 -0
- package/node/string/utils/index.d.ts +1 -0
- package/node/string/utils/index.js +17 -0
- package/node/string/utils/isString/index.d.ts +1 -0
- package/node/string/utils/isString/index.js +17 -0
- package/node/string/utils/isString/isString.d.ts +1 -0
- package/node/string/utils/isString/isString.js +5 -0
- package/node/textField/constants.d.ts +5 -0
- package/node/textField/constants.js +14 -0
- package/node/textField/index.d.ts +2 -0
- package/node/textField/index.js +18 -0
- package/node/textField/textField.d.ts +24 -0
- package/node/textField/textField.js +23 -0
- package/node/toPlainError/index.d.ts +1 -0
- package/node/toPlainError/index.js +17 -0
- package/node/toPlainError/toPlainError.d.ts +35 -0
- package/node/toPlainError/toPlainError.js +53 -0
- package/node/toPlainError/utils/generateArrayPath/generateArrayPath.d.ts +4 -0
- package/node/toPlainError/utils/generateArrayPath/generateArrayPath.js +13 -0
- package/node/toPlainError/utils/generateArrayPath/index.d.ts +1 -0
- package/node/toPlainError/utils/generateArrayPath/index.js +17 -0
- package/node/toPlainError/utils/generateObjectPath/generateObjectPath.d.ts +4 -0
- package/node/toPlainError/utils/generateObjectPath/generateObjectPath.js +13 -0
- package/node/toPlainError/utils/generateObjectPath/index.d.ts +1 -0
- package/node/toPlainError/utils/generateObjectPath/index.js +17 -0
- package/node/toPlainError/utils/index.d.ts +2 -0
- package/node/toPlainError/utils/index.js +18 -0
- package/node/toPrettyError/index.d.ts +1 -0
- package/node/toPrettyError/index.js +17 -0
- package/node/toPrettyError/toPrettyError.d.ts +39 -0
- package/node/toPrettyError/toPrettyError.js +42 -0
- package/node/transform/index.d.ts +1 -0
- package/node/transform/index.js +17 -0
- package/node/transform/transform.d.ts +18 -0
- package/node/transform/transform.js +20 -0
- package/node/uploadedFile/constants.d.ts +5 -0
- package/node/uploadedFile/constants.js +20 -0
- package/node/uploadedFile/index.d.ts +2 -0
- package/node/uploadedFile/index.js +18 -0
- package/node/uploadedFile/types.d.ts +46 -0
- package/node/uploadedFile/types.js +2 -0
- package/node/uploadedFile/uploadedFile.d.ts +30 -0
- package/node/uploadedFile/uploadedFile.js +64 -0
- package/node/uploadedFileList/constants.d.ts +2 -0
- package/node/uploadedFileList/constants.js +8 -0
- package/node/uploadedFileList/index.d.ts +2 -0
- package/node/uploadedFileList/index.js +18 -0
- package/node/uploadedFileList/uploadedFileList.d.ts +24 -0
- package/node/uploadedFileList/uploadedFileList.js +47 -0
- package/node/when/index.d.ts +1 -0
- package/node/when/index.js +17 -0
- package/node/when/when.d.ts +39 -0
- package/node/when/when.js +33 -0
- package/object/object.js +1 -1
- package/object/objectAsync/objectAsync.js +1 -1
- package/package.json +9 -6
@@ -0,0 +1,25 @@
|
|
1
|
+
type PositiveNumberParams = {
|
2
|
+
/**
|
3
|
+
* Замена стандартного сообщения ошибки.
|
4
|
+
*/
|
5
|
+
message?: string;
|
6
|
+
};
|
7
|
+
/**
|
8
|
+
* @description
|
9
|
+
* Проверяет является ли значение положительным числом.
|
10
|
+
* @example
|
11
|
+
* ```ts
|
12
|
+
* const validate = number(positiveNumber(3));
|
13
|
+
*
|
14
|
+
* // undefined
|
15
|
+
* validate(3)
|
16
|
+
*
|
17
|
+
* // { message: 'Только положительное числа' }
|
18
|
+
* validate(0)
|
19
|
+
*
|
20
|
+
* // { message: 'Только положительное числа' }
|
21
|
+
* validate(-1)
|
22
|
+
* ```
|
23
|
+
*/
|
24
|
+
export declare const positiveNumber: <TLastSchemaValues extends Record<string, unknown>>(params?: PositiveNumberParams) => (value: number, prevCtx?: import("../core").ValidationContext<TLastSchemaValues> | undefined) => import("../core").ValidationResult;
|
25
|
+
export {};
|
@@ -0,0 +1,35 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.positiveNumber = void 0;
|
4
|
+
const core_1 = require("../core");
|
5
|
+
const constants_1 = require("./constants");
|
6
|
+
const isPositiveNumber = (number) => {
|
7
|
+
return number > 0;
|
8
|
+
};
|
9
|
+
/**
|
10
|
+
* @description
|
11
|
+
* Проверяет является ли значение положительным числом.
|
12
|
+
* @example
|
13
|
+
* ```ts
|
14
|
+
* const validate = number(positiveNumber(3));
|
15
|
+
*
|
16
|
+
* // undefined
|
17
|
+
* validate(3)
|
18
|
+
*
|
19
|
+
* // { message: 'Только положительное числа' }
|
20
|
+
* validate(0)
|
21
|
+
*
|
22
|
+
* // { message: 'Только положительное числа' }
|
23
|
+
* validate(-1)
|
24
|
+
* ```
|
25
|
+
*/
|
26
|
+
const positiveNumber = (params) => (0, core_1.createRule)((value, ctx) => {
|
27
|
+
if (!isPositiveNumber(value)) {
|
28
|
+
return ctx.createError({
|
29
|
+
message: (params === null || params === void 0 ? void 0 : params.message) || constants_1.POSITIVE_NUMBER_ERROR_INFO.message,
|
30
|
+
code: constants_1.POSITIVE_NUMBER_ERROR_INFO.code,
|
31
|
+
});
|
32
|
+
}
|
33
|
+
return undefined;
|
34
|
+
});
|
35
|
+
exports.positiveNumber = positiveNumber;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { type ErrorInfo } from '../core';
|
2
|
+
export declare const RANGE_DATE_REQUIRED_ERROR_INFO: ErrorInfo;
|
3
|
+
export declare const RANGE_DATE_START_REQUIRED_ERROR_INFO: ErrorInfo;
|
4
|
+
export declare const RANGE_DATE_END_REQUIRED_ERROR_INFO: ErrorInfo;
|
5
|
+
export declare const RANGE_DATE_START_INVALID_ERROR_INFO: ErrorInfo;
|
6
|
+
export declare const RANGE_DATE_END_INVALID_ERROR_INFO: ErrorInfo;
|
7
|
+
export declare const RANGE_DATE_END_EARLIER_START_ERROR_INFO: ErrorInfo;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.RANGE_DATE_END_EARLIER_START_ERROR_INFO = exports.RANGE_DATE_END_INVALID_ERROR_INFO = exports.RANGE_DATE_START_INVALID_ERROR_INFO = exports.RANGE_DATE_END_REQUIRED_ERROR_INFO = exports.RANGE_DATE_START_REQUIRED_ERROR_INFO = exports.RANGE_DATE_REQUIRED_ERROR_INFO = void 0;
|
4
|
+
const core_1 = require("../core");
|
5
|
+
exports.RANGE_DATE_REQUIRED_ERROR_INFO = {
|
6
|
+
code: (0, core_1.createErrorCode)('rangedate-required'),
|
7
|
+
message: 'Укажите период',
|
8
|
+
};
|
9
|
+
exports.RANGE_DATE_START_REQUIRED_ERROR_INFO = {
|
10
|
+
code: (0, core_1.createErrorCode)('rangedate-startRequired'),
|
11
|
+
message: 'Укажите дату начала',
|
12
|
+
};
|
13
|
+
exports.RANGE_DATE_END_REQUIRED_ERROR_INFO = {
|
14
|
+
code: (0, core_1.createErrorCode)('rangedate-endRequired'),
|
15
|
+
message: 'Укажите дату окончания',
|
16
|
+
};
|
17
|
+
exports.RANGE_DATE_START_INVALID_ERROR_INFO = {
|
18
|
+
code: (0, core_1.createErrorCode)('rangedate-startInvalid'),
|
19
|
+
message: 'Дата начала некорректная',
|
20
|
+
};
|
21
|
+
exports.RANGE_DATE_END_INVALID_ERROR_INFO = {
|
22
|
+
code: (0, core_1.createErrorCode)('rangedate-endInvalid'),
|
23
|
+
message: 'Дата окончания некорректная',
|
24
|
+
};
|
25
|
+
exports.RANGE_DATE_END_EARLIER_START_ERROR_INFO = {
|
26
|
+
code: (0, core_1.createErrorCode)('rangedate-endEarlierStart'),
|
27
|
+
message: 'Дата окончания не может быть раньше даты начала',
|
28
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./constants"), exports);
|
18
|
+
__exportStar(require("./rangeDate"), exports);
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { type ValidationRule } from '../core';
|
2
|
+
type RangeDateValue = {
|
3
|
+
start?: Date;
|
4
|
+
end?: Date;
|
5
|
+
};
|
6
|
+
type RangeDateParams = {
|
7
|
+
/**
|
8
|
+
* Позволяет пометить дату как необязательная
|
9
|
+
*/
|
10
|
+
required?: {
|
11
|
+
/**
|
12
|
+
* Если `false` дата начала будет не обязательна
|
13
|
+
* @default true
|
14
|
+
*/
|
15
|
+
start?: boolean;
|
16
|
+
/**
|
17
|
+
* Если `false` дата окончания будет не обязательна
|
18
|
+
* @default true
|
19
|
+
*/
|
20
|
+
end?: boolean;
|
21
|
+
};
|
22
|
+
/**
|
23
|
+
* Позволяет переопределить дефолтные сообщения об ошибках
|
24
|
+
*/
|
25
|
+
messages?: {
|
26
|
+
/**
|
27
|
+
* Для даты начала
|
28
|
+
*/
|
29
|
+
startRequired?: string;
|
30
|
+
/**
|
31
|
+
* Для даты окончания
|
32
|
+
*/
|
33
|
+
endRequired?: string;
|
34
|
+
/**
|
35
|
+
* Если дата окончания раньше даты начала
|
36
|
+
*/
|
37
|
+
endEarlierStart?: string;
|
38
|
+
};
|
39
|
+
};
|
40
|
+
/**
|
41
|
+
* Guard для интервала дат. Проверяет даты интервала на обязательность заполнения, валидность значений и хронологический порядок
|
42
|
+
* @param rules - правила валидаций, применяющиеся к интервалу дат
|
43
|
+
* @example
|
44
|
+
* ```ts
|
45
|
+
* const validate = rangeDate();
|
46
|
+
* validate({ start: new Date(), end: new Date() });
|
47
|
+
* ```
|
48
|
+
*/
|
49
|
+
export declare const rangeDate: <TLastSchemaValues extends Record<string, unknown>>(...rules: ValidationRule<RangeDateValue, TLastSchemaValues>[]) => import("../core").Guard<TLastSchemaValues, RangeDateParams>;
|
50
|
+
export {};
|
@@ -0,0 +1,69 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.rangeDate = void 0;
|
4
|
+
const utils_1 = require("@astral/utils");
|
5
|
+
const core_1 = require("../core");
|
6
|
+
const constants_1 = require("./constants");
|
7
|
+
/**
|
8
|
+
* Guard для интервала дат. Проверяет даты интервала на обязательность заполнения, валидность значений и хронологический порядок
|
9
|
+
* @param rules - правила валидаций, применяющиеся к интервалу дат
|
10
|
+
* @example
|
11
|
+
* ```ts
|
12
|
+
* const validate = rangeDate();
|
13
|
+
* validate({ start: new Date(), end: new Date() });
|
14
|
+
* ```
|
15
|
+
*/
|
16
|
+
const rangeDate = (...rules) => (0, core_1.createGuard)((externalValue, ctx, params) => {
|
17
|
+
const { required, messages } = Object.assign(Object.assign({}, (params || {})), { required: {
|
18
|
+
start: (params === null || params === void 0 ? void 0 : params.required) && 'start' in (params === null || params === void 0 ? void 0 : params.required)
|
19
|
+
? params === null || params === void 0 ? void 0 : params.required.start
|
20
|
+
: true,
|
21
|
+
end: (params === null || params === void 0 ? void 0 : params.required) && 'end' in (params === null || params === void 0 ? void 0 : params.required)
|
22
|
+
? params === null || params === void 0 ? void 0 : params.required.end
|
23
|
+
: true,
|
24
|
+
} });
|
25
|
+
// Приводим тип, чтобы не усложнять код и не дублировать часть проверок
|
26
|
+
// Существующие проверки покрывают все кейсы
|
27
|
+
// Иначе необходимо делать проверку на объект и наличие полей start и end с учетом вариативности
|
28
|
+
const value = externalValue;
|
29
|
+
if ((required === null || required === void 0 ? void 0 : required.start) && (required === null || required === void 0 ? void 0 : required.end) && !value.start && !value.end) {
|
30
|
+
return ctx.createError({
|
31
|
+
message: constants_1.RANGE_DATE_REQUIRED_ERROR_INFO.message,
|
32
|
+
code: constants_1.RANGE_DATE_REQUIRED_ERROR_INFO.code,
|
33
|
+
});
|
34
|
+
}
|
35
|
+
if ((required === null || required === void 0 ? void 0 : required.start) && !value.start) {
|
36
|
+
return ctx.createError({
|
37
|
+
message: (messages === null || messages === void 0 ? void 0 : messages.startRequired) ||
|
38
|
+
constants_1.RANGE_DATE_START_REQUIRED_ERROR_INFO.message,
|
39
|
+
code: constants_1.RANGE_DATE_START_REQUIRED_ERROR_INFO.code,
|
40
|
+
});
|
41
|
+
}
|
42
|
+
if ((required === null || required === void 0 ? void 0 : required.end) && !value.end) {
|
43
|
+
return ctx.createError({
|
44
|
+
message: (messages === null || messages === void 0 ? void 0 : messages.endRequired) || constants_1.RANGE_DATE_END_REQUIRED_ERROR_INFO.message,
|
45
|
+
code: constants_1.RANGE_DATE_END_REQUIRED_ERROR_INFO.code,
|
46
|
+
});
|
47
|
+
}
|
48
|
+
if ((value === null || value === void 0 ? void 0 : value.start) && !(0, utils_1.isDate)(value.start)) {
|
49
|
+
return ctx.createError({
|
50
|
+
message: constants_1.RANGE_DATE_START_INVALID_ERROR_INFO.message,
|
51
|
+
code: constants_1.RANGE_DATE_START_INVALID_ERROR_INFO.code,
|
52
|
+
});
|
53
|
+
}
|
54
|
+
if ((value === null || value === void 0 ? void 0 : value.end) && !(0, utils_1.isDate)(value.end)) {
|
55
|
+
return ctx.createError({
|
56
|
+
message: constants_1.RANGE_DATE_END_INVALID_ERROR_INFO.message,
|
57
|
+
code: constants_1.RANGE_DATE_END_INVALID_ERROR_INFO.code,
|
58
|
+
});
|
59
|
+
}
|
60
|
+
if (value.end && value.start && (0, core_1.isDateEarlier)(value.end, value.start)) {
|
61
|
+
return ctx.createError({
|
62
|
+
message: (messages === null || messages === void 0 ? void 0 : messages.endEarlierStart) ||
|
63
|
+
constants_1.RANGE_DATE_END_EARLIER_START_ERROR_INFO.message,
|
64
|
+
code: constants_1.RANGE_DATE_END_EARLIER_START_ERROR_INFO.code,
|
65
|
+
});
|
66
|
+
}
|
67
|
+
return (0, core_1.compose)(...rules)(value, ctx);
|
68
|
+
});
|
69
|
+
exports.rangeDate = rangeDate;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.RANGE_DATE_INTERVAL_ERROR_INFO = void 0;
|
4
|
+
const utils_1 = require("@astral/utils");
|
5
|
+
const core_1 = require("../core");
|
6
|
+
const selectDeclensionUnitStrategy = (unit) => {
|
7
|
+
const strategy = {
|
8
|
+
day: utils_1.declensionDay,
|
9
|
+
month: utils_1.declensionMonth,
|
10
|
+
year: utils_1.declensionYear,
|
11
|
+
};
|
12
|
+
return strategy[unit];
|
13
|
+
};
|
14
|
+
exports.RANGE_DATE_INTERVAL_ERROR_INFO = {
|
15
|
+
code: (0, core_1.createErrorCode)('rangedate-interval'),
|
16
|
+
message: (limit, unit) => `Период не может превышать ${limit} ${selectDeclensionUnitStrategy(unit)(limit)}`,
|
17
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./constants"), exports);
|
18
|
+
__exportStar(require("./rangeDateInterval"), exports);
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import type { DateUnit, RangeDateValue } from './types';
|
2
|
+
type RangeDateIntervalParams = {
|
3
|
+
limit: number;
|
4
|
+
/**
|
5
|
+
* Еденицы измерения лимита
|
6
|
+
* @default 'day'
|
7
|
+
*/
|
8
|
+
unit?: DateUnit;
|
9
|
+
/**
|
10
|
+
* Замена стандартного сообщения об ошибки
|
11
|
+
*/
|
12
|
+
message?: string;
|
13
|
+
};
|
14
|
+
/**
|
15
|
+
* Позволяет ограничить интервал на конкретное значение. Установка интревала возможна в следующих единицах: день, месяц и год.
|
16
|
+
* @example
|
17
|
+
* ```ts
|
18
|
+
* const validate = rangeDate(rangeDateInterval({ limit: 14 }));
|
19
|
+
* validate({ start: new Date('2024.08.15'), end: new Date('2024.09.05') });
|
20
|
+
* ```
|
21
|
+
*/
|
22
|
+
export declare const rangeDateInterval: <TLastSchemaValues extends Record<string, unknown>>(params: RangeDateIntervalParams) => (value: RangeDateValue, prevCtx?: import("../core").ValidationContext<TLastSchemaValues> | undefined) => import("../core").ValidationResult;
|
23
|
+
export {};
|
@@ -0,0 +1,40 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.rangeDateInterval = void 0;
|
4
|
+
const utils_1 = require("@astral/utils");
|
5
|
+
const core_1 = require("../core");
|
6
|
+
const constants_1 = require("./constants");
|
7
|
+
const selectAddingStrategy = (unit) => {
|
8
|
+
const strategy = {
|
9
|
+
day: utils_1.addDays,
|
10
|
+
month: utils_1.addMonths,
|
11
|
+
year: utils_1.addYears,
|
12
|
+
};
|
13
|
+
return strategy[unit];
|
14
|
+
};
|
15
|
+
/**
|
16
|
+
* Позволяет ограничить интервал на конкретное значение. Установка интревала возможна в следующих единицах: день, месяц и год.
|
17
|
+
* @example
|
18
|
+
* ```ts
|
19
|
+
* const validate = rangeDate(rangeDateInterval({ limit: 14 }));
|
20
|
+
* validate({ start: new Date('2024.08.15'), end: new Date('2024.09.05') });
|
21
|
+
* ```
|
22
|
+
*/
|
23
|
+
const rangeDateInterval = (params) => (0, core_1.createRule)((value, ctx) => {
|
24
|
+
const { limit, unit = 'day', message } = params;
|
25
|
+
if (!value.start || !value.end) {
|
26
|
+
return undefined;
|
27
|
+
}
|
28
|
+
if (!(0, utils_1.isDate)(value.start) || !(0, utils_1.isDate)(value.end)) {
|
29
|
+
return undefined;
|
30
|
+
}
|
31
|
+
const addLimits = selectAddingStrategy(unit);
|
32
|
+
if (!(0, core_1.isDateEarlier)(value.end, addLimits(value.start, limit))) {
|
33
|
+
return ctx.createError({
|
34
|
+
message: message || constants_1.RANGE_DATE_INTERVAL_ERROR_INFO.message(limit, unit),
|
35
|
+
code: constants_1.RANGE_DATE_INTERVAL_ERROR_INFO.code,
|
36
|
+
});
|
37
|
+
}
|
38
|
+
return undefined;
|
39
|
+
});
|
40
|
+
exports.rangeDateInterval = rangeDateInterval;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { type ErrorInfo } from '../core';
|
2
|
+
import type { DefaultMessage } from './types';
|
3
|
+
type DynamicErrorInfo = Pick<ErrorInfo, 'code'> & {
|
4
|
+
message: DefaultMessage;
|
5
|
+
};
|
6
|
+
export declare const RANGE_DATE_MIN_ERROR_INFO: DynamicErrorInfo;
|
7
|
+
export declare const RANGE_DATE_MAX_ERROR_INFO: DynamicErrorInfo;
|
8
|
+
export {};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.RANGE_DATE_MAX_ERROR_INFO = exports.RANGE_DATE_MIN_ERROR_INFO = void 0;
|
4
|
+
const core_1 = require("../core");
|
5
|
+
const DEFAULT_FIELD_NAME = {
|
6
|
+
start: 'начала',
|
7
|
+
end: 'окончания',
|
8
|
+
};
|
9
|
+
exports.RANGE_DATE_MIN_ERROR_INFO = {
|
10
|
+
code: (0, core_1.createErrorCode)('rangedate-min'),
|
11
|
+
message: (field, minDate) => `Дата ${DEFAULT_FIELD_NAME[field]} должна быть позже ${minDate}`,
|
12
|
+
};
|
13
|
+
exports.RANGE_DATE_MAX_ERROR_INFO = {
|
14
|
+
code: (0, core_1.createErrorCode)('rangedate-max'),
|
15
|
+
message: (field, maxDate) => `Дата ${DEFAULT_FIELD_NAME[field]} должна быть раньше ${maxDate}`,
|
16
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./constants"), exports);
|
18
|
+
__exportStar(require("./rangeDateMinMax"), exports);
|
@@ -0,0 +1,34 @@
|
|
1
|
+
type RangeDateValue = {
|
2
|
+
start?: Date;
|
3
|
+
end?: Date;
|
4
|
+
};
|
5
|
+
type LimitOptions = {
|
6
|
+
/**
|
7
|
+
* Дата
|
8
|
+
*/
|
9
|
+
limit: Date;
|
10
|
+
/**
|
11
|
+
* Замена стандартного сообщения ошибки
|
12
|
+
*/
|
13
|
+
message?: (field: 'start' | 'end', date: string) => string;
|
14
|
+
};
|
15
|
+
type RangeDateMinMaxParams = {
|
16
|
+
start?: {
|
17
|
+
min?: LimitOptions;
|
18
|
+
max?: LimitOptions;
|
19
|
+
};
|
20
|
+
end?: {
|
21
|
+
min?: LimitOptions;
|
22
|
+
max?: LimitOptions;
|
23
|
+
};
|
24
|
+
};
|
25
|
+
/**
|
26
|
+
* Проверяет даты на минимальное и максимальное допустимое значение
|
27
|
+
* @example
|
28
|
+
* ```ts
|
29
|
+
* const validate = rangeDate(rangeDateMinMax({ start: { min: { limit: new Date(2023, 0, 1) }}, end: { max: { limit: new Date() } } }));
|
30
|
+
* validate({ start: new Date(), end: new Date() });
|
31
|
+
* ```
|
32
|
+
*/
|
33
|
+
export declare const rangeDateMinMax: <TLastSchemaValues extends Record<string, unknown>>(params?: RangeDateMinMaxParams) => (value: RangeDateValue, prevCtx?: import("../core").ValidationContext<TLastSchemaValues> | undefined) => import("../core").ValidationResult;
|
34
|
+
export {};
|
@@ -0,0 +1,78 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.rangeDateMinMax = void 0;
|
4
|
+
const utils_1 = require("@astral/utils");
|
5
|
+
const core_1 = require("../core");
|
6
|
+
const rangeDate_1 = require("../rangeDate");
|
7
|
+
const constants_1 = require("./constants");
|
8
|
+
const formatDateToView = (date) => {
|
9
|
+
return new Intl.DateTimeFormat('ru-RU').format(date);
|
10
|
+
};
|
11
|
+
/**
|
12
|
+
* Проверяет даты на минимальное и максимальное допустимое значение
|
13
|
+
* @example
|
14
|
+
* ```ts
|
15
|
+
* const validate = rangeDate(rangeDateMinMax({ start: { min: { limit: new Date(2023, 0, 1) }}, end: { max: { limit: new Date() } } }));
|
16
|
+
* validate({ start: new Date(), end: new Date() });
|
17
|
+
* ```
|
18
|
+
*/
|
19
|
+
const rangeDateMinMax = (params) => (0, core_1.createRule)((value, ctx) => {
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
21
|
+
if (!value.start && !value.end) {
|
22
|
+
return undefined;
|
23
|
+
}
|
24
|
+
if ((value === null || value === void 0 ? void 0 : value.start) && !(0, utils_1.isDate)(value.start)) {
|
25
|
+
return ctx.createError({
|
26
|
+
message: rangeDate_1.RANGE_DATE_START_INVALID_ERROR_INFO.message,
|
27
|
+
code: rangeDate_1.RANGE_DATE_START_INVALID_ERROR_INFO.code,
|
28
|
+
});
|
29
|
+
}
|
30
|
+
if ((value === null || value === void 0 ? void 0 : value.end) && !(0, utils_1.isDate)(value.end)) {
|
31
|
+
return ctx.createError({
|
32
|
+
message: rangeDate_1.RANGE_DATE_END_INVALID_ERROR_INFO.message,
|
33
|
+
code: rangeDate_1.RANGE_DATE_END_INVALID_ERROR_INFO.code,
|
34
|
+
});
|
35
|
+
}
|
36
|
+
// Если дата начала раньше заданной минимальной
|
37
|
+
if (((_b = (_a = params === null || params === void 0 ? void 0 : params.start) === null || _a === void 0 ? void 0 : _a.min) === null || _b === void 0 ? void 0 : _b.limit) &&
|
38
|
+
value.start &&
|
39
|
+
(0, core_1.isDateEarlier)(value.start, (_c = params === null || params === void 0 ? void 0 : params.start.min) === null || _c === void 0 ? void 0 : _c.limit)) {
|
40
|
+
return ctx.createError({
|
41
|
+
message: ((_e = (_d = params.start.min).message) === null || _e === void 0 ? void 0 : _e.call(_d, 'start', formatDateToView(params.start.min.limit))) ||
|
42
|
+
constants_1.RANGE_DATE_MIN_ERROR_INFO.message('start', formatDateToView(params.start.min.limit)),
|
43
|
+
code: constants_1.RANGE_DATE_MIN_ERROR_INFO.code,
|
44
|
+
});
|
45
|
+
}
|
46
|
+
// Если дата начала позже заданной максимальной
|
47
|
+
if (((_g = (_f = params === null || params === void 0 ? void 0 : params.start) === null || _f === void 0 ? void 0 : _f.max) === null || _g === void 0 ? void 0 : _g.limit) &&
|
48
|
+
value.start &&
|
49
|
+
(0, core_1.isDateEarlier)((_h = params === null || params === void 0 ? void 0 : params.start.max) === null || _h === void 0 ? void 0 : _h.limit, value.start)) {
|
50
|
+
return ctx.createError({
|
51
|
+
message: ((_k = (_j = params.start.max).message) === null || _k === void 0 ? void 0 : _k.call(_j, 'start', formatDateToView(params.start.max.limit))) ||
|
52
|
+
constants_1.RANGE_DATE_MAX_ERROR_INFO.message('start', formatDateToView(params.start.max.limit)),
|
53
|
+
code: constants_1.RANGE_DATE_MAX_ERROR_INFO.code,
|
54
|
+
});
|
55
|
+
}
|
56
|
+
// Если дата окончания раньше заданной минимальной
|
57
|
+
if (((_m = (_l = params === null || params === void 0 ? void 0 : params.end) === null || _l === void 0 ? void 0 : _l.min) === null || _m === void 0 ? void 0 : _m.limit) &&
|
58
|
+
value.end &&
|
59
|
+
(0, core_1.isDateEarlier)(value.end, (_o = params === null || params === void 0 ? void 0 : params.end.min) === null || _o === void 0 ? void 0 : _o.limit)) {
|
60
|
+
return ctx.createError({
|
61
|
+
message: ((_q = (_p = params.end.min).message) === null || _q === void 0 ? void 0 : _q.call(_p, 'start', formatDateToView(params.end.min.limit))) ||
|
62
|
+
constants_1.RANGE_DATE_MIN_ERROR_INFO.message('end', formatDateToView(params.end.min.limit)),
|
63
|
+
code: constants_1.RANGE_DATE_MIN_ERROR_INFO.code,
|
64
|
+
});
|
65
|
+
}
|
66
|
+
// Если дата окончания позже заданной максимально
|
67
|
+
if (((_s = (_r = params === null || params === void 0 ? void 0 : params.end) === null || _r === void 0 ? void 0 : _r.max) === null || _s === void 0 ? void 0 : _s.limit) &&
|
68
|
+
value.end &&
|
69
|
+
(0, core_1.isDateEarlier)((_t = params === null || params === void 0 ? void 0 : params.end.max) === null || _t === void 0 ? void 0 : _t.limit, value.end)) {
|
70
|
+
return ctx.createError({
|
71
|
+
message: ((_v = (_u = params.end.max).message) === null || _v === void 0 ? void 0 : _v.call(_u, 'start', formatDateToView(params.end.max.limit))) ||
|
72
|
+
constants_1.RANGE_DATE_MAX_ERROR_INFO.message('end', formatDateToView(params.end.max.limit)),
|
73
|
+
code: constants_1.RANGE_DATE_MAX_ERROR_INFO.code,
|
74
|
+
});
|
75
|
+
}
|
76
|
+
return undefined;
|
77
|
+
});
|
78
|
+
exports.rangeDateMinMax = rangeDateMinMax;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.RANGE_DATE_NOT_EQUAL_ERROR_INFO = void 0;
|
4
|
+
const core_1 = require("../core");
|
5
|
+
exports.RANGE_DATE_NOT_EQUAL_ERROR_INFO = {
|
6
|
+
code: (0, core_1.createErrorCode)('rangedate-notequal'),
|
7
|
+
message: 'Даты начала и окончания не могут совпадать',
|
8
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./constants"), exports);
|
18
|
+
__exportStar(require("./rangeDateNotEqual"), exports);
|
@@ -0,0 +1,20 @@
|
|
1
|
+
type RangeDateValue = {
|
2
|
+
start?: Date;
|
3
|
+
end?: Date;
|
4
|
+
};
|
5
|
+
type RangeDateNotEqualParams = {
|
6
|
+
/**
|
7
|
+
* Замена стандартного сообщения ошибки
|
8
|
+
*/
|
9
|
+
message?: string;
|
10
|
+
};
|
11
|
+
/**
|
12
|
+
* Проверяет даты интервала на совпадение даты начала и окончания
|
13
|
+
* @example
|
14
|
+
* ```ts
|
15
|
+
* const validate = rangeDate(rangeDateNotEqual());
|
16
|
+
* validate({ start: new Date(), end: new Date() });
|
17
|
+
* ```
|
18
|
+
*/
|
19
|
+
export declare const rangeDateNotEqual: <TLastSchemaValues extends Record<string, unknown>>(params?: RangeDateNotEqualParams) => (value: RangeDateValue, prevCtx?: import("../core").ValidationContext<TLastSchemaValues> | undefined) => import("../core").ValidationResult;
|
20
|
+
export {};
|
@@ -0,0 +1,33 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.rangeDateNotEqual = void 0;
|
4
|
+
const utils_1 = require("@astral/utils");
|
5
|
+
const core_1 = require("../core");
|
6
|
+
const constants_1 = require("./constants");
|
7
|
+
const isDateEqual = (dateA, dateB) => {
|
8
|
+
return (0, core_1.resetTime)(dateA).getTime() === (0, core_1.resetTime)(dateB).getTime();
|
9
|
+
};
|
10
|
+
/**
|
11
|
+
* Проверяет даты интервала на совпадение даты начала и окончания
|
12
|
+
* @example
|
13
|
+
* ```ts
|
14
|
+
* const validate = rangeDate(rangeDateNotEqual());
|
15
|
+
* validate({ start: new Date(), end: new Date() });
|
16
|
+
* ```
|
17
|
+
*/
|
18
|
+
const rangeDateNotEqual = (params) => (0, core_1.createRule)((value, ctx) => {
|
19
|
+
if (!value.start || !value.end) {
|
20
|
+
return undefined;
|
21
|
+
}
|
22
|
+
if (!(0, utils_1.isDate)(value.start) || !(0, utils_1.isDate)(value.end)) {
|
23
|
+
return undefined;
|
24
|
+
}
|
25
|
+
if (isDateEqual(value.start, value.end)) {
|
26
|
+
return ctx.createError({
|
27
|
+
message: (params === null || params === void 0 ? void 0 : params.message) || constants_1.RANGE_DATE_NOT_EQUAL_ERROR_INFO.message,
|
28
|
+
code: constants_1.RANGE_DATE_NOT_EQUAL_ERROR_INFO.code,
|
29
|
+
});
|
30
|
+
}
|
31
|
+
return undefined;
|
32
|
+
});
|
33
|
+
exports.rangeDateNotEqual = rangeDateNotEqual;
|