@astral/validations 4.20.3 → 4.20.4
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 +57 -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 +79 -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/package.json +7 -3
@@ -0,0 +1,26 @@
|
|
1
|
+
import { type ValidationContext, createRule } from '../core';
|
2
|
+
type BaseMinValidationTypes = number | string | Array<unknown>;
|
3
|
+
type CommonThreshold = number | Date;
|
4
|
+
type MinParams<ValidationType> = {
|
5
|
+
/**
|
6
|
+
* Сообщение ошибки
|
7
|
+
*/
|
8
|
+
getMessage?: (threshold: CommonThreshold, value: ValidationType, ctx: ValidationContext) => string;
|
9
|
+
};
|
10
|
+
/**
|
11
|
+
* Проверяет значение на соответствие минимуму. Работает с: string, array, Date, number
|
12
|
+
* @param threshold - нижний доступный порог value
|
13
|
+
* @example
|
14
|
+
* ```ts
|
15
|
+
* string(min(22));
|
16
|
+
*
|
17
|
+
* number(min(22));
|
18
|
+
*
|
19
|
+
* array(min(2)));
|
20
|
+
*
|
21
|
+
* date(min(new Date())));
|
22
|
+
* ```
|
23
|
+
*/
|
24
|
+
export declare function min<ValidationType extends Date, TLastSchemaValues extends Record<string, unknown> = {}>(threshold: Date, params?: MinParams<ValidationType>): ReturnType<typeof createRule<Date, TLastSchemaValues>>;
|
25
|
+
export declare function min<ValidationType extends BaseMinValidationTypes, TLastSchemaValues extends Record<string, unknown> = {}>(threshold: number, params?: MinParams<ValidationType>): ReturnType<typeof createRule<BaseMinValidationTypes, TLastSchemaValues>>;
|
26
|
+
export {};
|
package/node/min/min.js
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.min = void 0;
|
4
|
+
const core_1 = require("../core");
|
5
|
+
const constants_1 = require("./constants");
|
6
|
+
function min(threshold, params) {
|
7
|
+
return (0, core_1.createRule)((value, ctx) => {
|
8
|
+
const getMessage = (typeMessage) => (params === null || params === void 0 ? void 0 : params.getMessage)
|
9
|
+
? params.getMessage(threshold, value, ctx)
|
10
|
+
: typeMessage;
|
11
|
+
if (value instanceof Date && threshold instanceof Date) {
|
12
|
+
return (0, core_1.resetTime)(value) >= (0, core_1.resetTime)(threshold)
|
13
|
+
? undefined
|
14
|
+
: ctx.createError({
|
15
|
+
code: constants_1.DATE_MIN_ERROR_CODE,
|
16
|
+
message: getMessage(`Не раньше ${threshold.toLocaleDateString('ru')}`),
|
17
|
+
});
|
18
|
+
}
|
19
|
+
if (threshold instanceof Date) {
|
20
|
+
return undefined;
|
21
|
+
}
|
22
|
+
if (typeof value === 'string') {
|
23
|
+
const isError = value.trim().length < threshold;
|
24
|
+
return isError
|
25
|
+
? ctx.createError({
|
26
|
+
code: constants_1.STRING_MIN_ERROR_CODE,
|
27
|
+
message: getMessage(`Мин. символов: ${threshold}`),
|
28
|
+
})
|
29
|
+
: undefined;
|
30
|
+
}
|
31
|
+
if (Array.isArray(value) && value.length < threshold) {
|
32
|
+
return ctx.createError({
|
33
|
+
code: constants_1.ARRAY_MIN_ERROR_CODE,
|
34
|
+
message: getMessage(`Не меньше ${threshold}`),
|
35
|
+
});
|
36
|
+
}
|
37
|
+
if (typeof value === 'number' && value < threshold) {
|
38
|
+
return ctx.createError({
|
39
|
+
code: constants_1.NUMBER_MIN_ERROR_CODE,
|
40
|
+
message: getMessage(`Не меньше ${threshold}`),
|
41
|
+
});
|
42
|
+
}
|
43
|
+
return undefined;
|
44
|
+
});
|
45
|
+
}
|
46
|
+
exports.min = min;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.BIRTH_DATE_MIN = exports.BIRTH_DATE_MIN_ERROR_CODE = exports.BIRTH_DATE_MAX_ERROR_CODE = void 0;
|
4
|
+
const core_1 = require("../core");
|
5
|
+
exports.BIRTH_DATE_MAX_ERROR_CODE = (0, core_1.createErrorCode)('birth-date-max');
|
6
|
+
exports.BIRTH_DATE_MIN_ERROR_CODE = (0, core_1.createErrorCode)('birth-date-min');
|
7
|
+
exports.BIRTH_DATE_MIN = new Date('01.01.1900');
|
@@ -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("./minYearsOld"), exports);
|
18
|
+
__exportStar(require("./constants"), exports);
|
@@ -0,0 +1,24 @@
|
|
1
|
+
type MinYearsOldParams = {
|
2
|
+
/**
|
3
|
+
* Кастомное сообщение ошибки
|
4
|
+
*/
|
5
|
+
customErrorMessage: string;
|
6
|
+
};
|
7
|
+
/**
|
8
|
+
* Проверяет дату рождения на соответствие условию. Работает с date.
|
9
|
+
* @param age - ограничение по возрасту (коло-во лет, вычитаемое из текущей даты для валидации)
|
10
|
+
* @param params - объект параметров
|
11
|
+
* @example
|
12
|
+
* ```ts
|
13
|
+
|
14
|
+
*
|
15
|
+
* const validate = date(
|
16
|
+
* minYearsOld(18, {
|
17
|
+
* customMessage:
|
18
|
+
* 'Только совершеннолетние могут воспользоваться данной услугой',
|
19
|
+
* }),
|
20
|
+
* );
|
21
|
+
* ```
|
22
|
+
*/
|
23
|
+
export declare function minYearsOld<ValidationType, TLastSchemaValues extends Record<string, unknown> = {}>(age: number, params?: MinYearsOldParams): (value: ValidationType, prevCtx?: import("../core").ValidationContext<TLastSchemaValues> | undefined) => import("../core").ValidationResult;
|
24
|
+
export {};
|
@@ -0,0 +1,48 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.minYearsOld = void 0;
|
4
|
+
const core_1 = require("../core");
|
5
|
+
const constants_1 = require("./constants");
|
6
|
+
/**
|
7
|
+
* Проверяет дату рождения на соответствие условию. Работает с date.
|
8
|
+
* @param age - ограничение по возрасту (коло-во лет, вычитаемое из текущей даты для валидации)
|
9
|
+
* @param params - объект параметров
|
10
|
+
* @example
|
11
|
+
* ```ts
|
12
|
+
|
13
|
+
*
|
14
|
+
* const validate = date(
|
15
|
+
* minYearsOld(18, {
|
16
|
+
* customMessage:
|
17
|
+
* 'Только совершеннолетние могут воспользоваться данной услугой',
|
18
|
+
* }),
|
19
|
+
* );
|
20
|
+
* ```
|
21
|
+
*/
|
22
|
+
function minYearsOld(age, params) {
|
23
|
+
return (0, core_1.createRule)((value, ctx) => {
|
24
|
+
const getMessage = (typeMessage) => {
|
25
|
+
const message = params === null || params === void 0 ? void 0 : params.customErrorMessage;
|
26
|
+
return message ? message : typeMessage;
|
27
|
+
};
|
28
|
+
const threshold = new Date();
|
29
|
+
threshold.setFullYear(threshold.getFullYear() - age);
|
30
|
+
if (value instanceof Date && value > constants_1.BIRTH_DATE_MIN) {
|
31
|
+
if (value > threshold) {
|
32
|
+
return ctx.createError({
|
33
|
+
code: constants_1.BIRTH_DATE_MAX_ERROR_CODE,
|
34
|
+
message: getMessage(`Вам должно быть больше ${age} лет`),
|
35
|
+
});
|
36
|
+
}
|
37
|
+
return undefined;
|
38
|
+
}
|
39
|
+
if (value < constants_1.BIRTH_DATE_MIN) {
|
40
|
+
return ctx.createError({
|
41
|
+
code: constants_1.BIRTH_DATE_MIN_ERROR_CODE,
|
42
|
+
message: getMessage(`Не ранее ${constants_1.BIRTH_DATE_MIN}`),
|
43
|
+
});
|
44
|
+
}
|
45
|
+
return undefined;
|
46
|
+
});
|
47
|
+
}
|
48
|
+
exports.minYearsOld = minYearsOld;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.MOBILE_PHONE_REGEX = exports.MOBILE_PHONE_ERROR_INFO = void 0;
|
4
|
+
const core_1 = require("../core");
|
5
|
+
exports.MOBILE_PHONE_ERROR_INFO = {
|
6
|
+
code: (0, core_1.createErrorCode)('mobilePhone'),
|
7
|
+
message: 'Некорректный номер телефона',
|
8
|
+
};
|
9
|
+
exports.MOBILE_PHONE_REGEX = /^(79)\d{9}$/;
|
@@ -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("./mobilePhone"), exports);
|
18
|
+
__exportStar(require("./constants"), exports);
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { type CommonRuleParams } from '../core';
|
2
|
+
type MobilePhoneParams = CommonRuleParams<string> & {
|
3
|
+
/**
|
4
|
+
* Замена стандартного сообщения ошибки.
|
5
|
+
*/
|
6
|
+
message?: string;
|
7
|
+
};
|
8
|
+
/**
|
9
|
+
* @description
|
10
|
+
* Проверяет валиден ли мобильный телефон.
|
11
|
+
* Валидный телефон начинается с "79" и не содержит символов, кроме цифр.
|
12
|
+
* @example
|
13
|
+
* ```ts
|
14
|
+
* const validate = string(mobilePhone());
|
15
|
+
* validate('79999999999');
|
16
|
+
* ```
|
17
|
+
*/
|
18
|
+
export declare const mobilePhone: <TLastSchemaValues extends Record<string, unknown>>(params?: MobilePhoneParams) => (value: string, prevCtx?: import("../core").ValidationContext<TLastSchemaValues> | undefined) => import("../core").ValidationResult;
|
19
|
+
export {};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.mobilePhone = void 0;
|
4
|
+
const core_1 = require("../core");
|
5
|
+
const constants_1 = require("./constants");
|
6
|
+
/**
|
7
|
+
* @description
|
8
|
+
* Проверяет валиден ли мобильный телефон.
|
9
|
+
* Валидный телефон начинается с "79" и не содержит символов, кроме цифр.
|
10
|
+
* @example
|
11
|
+
* ```ts
|
12
|
+
* const validate = string(mobilePhone());
|
13
|
+
* validate('79999999999');
|
14
|
+
* ```
|
15
|
+
*/
|
16
|
+
const mobilePhone = (params) => (0, core_1.createRule)((value, ctx) => {
|
17
|
+
if (!constants_1.MOBILE_PHONE_REGEX.test(value)) {
|
18
|
+
return ctx.createError({
|
19
|
+
message: (params === null || params === void 0 ? void 0 : params.message) || constants_1.MOBILE_PHONE_ERROR_INFO.message,
|
20
|
+
code: constants_1.MOBILE_PHONE_ERROR_INFO.code,
|
21
|
+
});
|
22
|
+
}
|
23
|
+
return undefined;
|
24
|
+
}, { exclude: params === null || params === void 0 ? void 0 : params.exclude });
|
25
|
+
exports.mobilePhone = mobilePhone;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.INFINITY_NUMBER_ERROR_INFO = exports.NAN_NUMBER_ERROR_INFO = exports.NUMBER_TYPE_ERROR_INFO = void 0;
|
4
|
+
const core_1 = require("../core");
|
5
|
+
exports.NUMBER_TYPE_ERROR_INFO = {
|
6
|
+
code: (0, core_1.createErrorCode)('number-type'),
|
7
|
+
message: 'Не число',
|
8
|
+
};
|
9
|
+
exports.NAN_NUMBER_ERROR_INFO = {
|
10
|
+
code: (0, core_1.createErrorCode)('number-nan'),
|
11
|
+
message: 'Некорректное число',
|
12
|
+
};
|
13
|
+
exports.INFINITY_NUMBER_ERROR_INFO = {
|
14
|
+
code: (0, core_1.createErrorCode)('number-infinity'),
|
15
|
+
message: 'Бесконечное число',
|
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("./number"), exports);
|
18
|
+
__exportStar(require("./constants"), exports);
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { type ValidationRule } from '../core';
|
2
|
+
type AdditionalDefOptions = {
|
3
|
+
nanErrorMessage?: string;
|
4
|
+
infinityErrorMessage?: string;
|
5
|
+
};
|
6
|
+
/**
|
7
|
+
* Guard для number. Проверяет значение на тип number и NaN, Infinity
|
8
|
+
* Для NaN и Infinity возвращаются отдельные ошибки
|
9
|
+
* @param rules - правила, валидирующие number или unknown value
|
10
|
+
* @example
|
11
|
+
* ```ts
|
12
|
+
* const validate = number(min(22));
|
13
|
+
*
|
14
|
+
* // undefined
|
15
|
+
* validate(24);
|
16
|
+
* ```
|
17
|
+
*/
|
18
|
+
export declare const number: <TLastSchemaValues extends Record<string, unknown>>(...rules: ValidationRule<number, TLastSchemaValues>[]) => import("../core").Guard<TLastSchemaValues, AdditionalDefOptions>;
|
19
|
+
export {};
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.number = void 0;
|
4
|
+
const core_1 = require("../core");
|
5
|
+
const constants_1 = require("./constants");
|
6
|
+
/**
|
7
|
+
* Guard для number. Проверяет значение на тип number и NaN, Infinity
|
8
|
+
* Для NaN и Infinity возвращаются отдельные ошибки
|
9
|
+
* @param rules - правила, валидирующие number или unknown value
|
10
|
+
* @example
|
11
|
+
* ```ts
|
12
|
+
* const validate = number(min(22));
|
13
|
+
*
|
14
|
+
* // undefined
|
15
|
+
* validate(24);
|
16
|
+
* ```
|
17
|
+
*/
|
18
|
+
const number = (...rules) => (0, core_1.createGuard)((value, ctx, { typeErrorMessage, nanErrorMessage, infinityErrorMessage }) => {
|
19
|
+
if (typeof value !== 'number') {
|
20
|
+
return ctx.createError(Object.assign(Object.assign({}, constants_1.NUMBER_TYPE_ERROR_INFO), { message: typeErrorMessage || constants_1.NUMBER_TYPE_ERROR_INFO.message }));
|
21
|
+
}
|
22
|
+
if (Number.isNaN(value)) {
|
23
|
+
return ctx.createError(Object.assign(Object.assign({}, constants_1.NAN_NUMBER_ERROR_INFO), { message: nanErrorMessage || constants_1.NAN_NUMBER_ERROR_INFO.message }));
|
24
|
+
}
|
25
|
+
if (!Number.isFinite(value)) {
|
26
|
+
return ctx.createError(Object.assign(Object.assign({}, constants_1.INFINITY_NUMBER_ERROR_INFO), { message: infinityErrorMessage || constants_1.INFINITY_NUMBER_ERROR_INFO.message }));
|
27
|
+
}
|
28
|
+
return (0, core_1.compose)(...rules)(value, ctx);
|
29
|
+
});
|
30
|
+
exports.number = number;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.OBJECT_TYPE_ERROR_INFO = void 0;
|
4
|
+
const core_1 = require("../core");
|
5
|
+
exports.OBJECT_TYPE_ERROR_INFO = {
|
6
|
+
code: (0, core_1.createErrorCode)('object'),
|
7
|
+
message: 'Не является объектом',
|
8
|
+
};
|
@@ -0,0 +1,19 @@
|
|
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("./object"), exports);
|
18
|
+
__exportStar(require("./constants"), exports);
|
19
|
+
__exportStar(require("./objectAsync"), exports);
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './isEmptyErrors';
|
@@ -0,0 +1,17 @@
|
|
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("./isEmptyErrors"), exports);
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isEmptyErrors = void 0;
|
4
|
+
/**
|
5
|
+
* Проверяет есть ли errorMap ошибки
|
6
|
+
*/
|
7
|
+
const isEmptyErrors = (errorMap) => Object.values(errorMap).every((error) => error === undefined);
|
8
|
+
exports.isEmptyErrors = isEmptyErrors;
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { type Guard, type ValidationContext, type ValidationRule } from '../core';
|
2
|
+
/**
|
3
|
+
* Специальный итерфейс Guard для object. В данном интерфейсе ctx required
|
4
|
+
* Переопределение необходимо для того, чтобы ts показывал, что ctx required в кастомных правилах
|
5
|
+
*/
|
6
|
+
interface ObjectPropGuard<TLastSchemaValues extends Record<string, unknown>> {
|
7
|
+
(value: Parameters<Guard<TLastSchemaValues>>[0], ctx: ValidationContext<TLastSchemaValues>): ReturnType<Guard<TLastSchemaValues>>;
|
8
|
+
define: Guard<TLastSchemaValues>['define'];
|
9
|
+
}
|
10
|
+
type AdditionalDefOptions = {
|
11
|
+
/**
|
12
|
+
* Делает все свойства объекта partial
|
13
|
+
*/
|
14
|
+
isPartial?: boolean;
|
15
|
+
};
|
16
|
+
/**
|
17
|
+
* Возможные значения, принимаемые схемой
|
18
|
+
*/
|
19
|
+
export type SchemaValue<TValue extends Record<string, unknown>> = ObjectPropGuard<TValue> | ValidationRule<unknown, TValue>;
|
20
|
+
/**
|
21
|
+
* Схема правил валдиации для объекта
|
22
|
+
*/
|
23
|
+
export type Schema<TValue extends Record<string, unknown>> = Record<keyof TValue, SchemaValue<TValue>>;
|
24
|
+
/**
|
25
|
+
* Guard для объекта
|
26
|
+
* @param schema - схема валидации объекта
|
27
|
+
* @example
|
28
|
+
* ```ts
|
29
|
+
* type Values = {
|
30
|
+
* name: string;
|
31
|
+
* age?: number;
|
32
|
+
* info: { surname: string };
|
33
|
+
* };
|
34
|
+
*
|
35
|
+
* const values: Values = { name: 'Vasya', info: { surname: 'Vasin' } };
|
36
|
+
*
|
37
|
+
* const validateObject = object<Values>({
|
38
|
+
* name: string(min(2)),
|
39
|
+
* age: optional(number()),
|
40
|
+
* info: object<Values['info']>({ surname: string(min(2)) }),
|
41
|
+
* customField: (value, ctx) => {
|
42
|
+
* return ctx.createError({ message: 'error', code: 'custom error' })
|
43
|
+
* }
|
44
|
+
* });
|
45
|
+
* ```
|
46
|
+
*/
|
47
|
+
export declare const object: <TValue extends Record<string, unknown>, TLastSchemaValues extends Record<string, unknown> = {}>(schema: Schema<TValue>) => Guard<TLastSchemaValues, AdditionalDefOptions>;
|
48
|
+
export type ObjectGuard<TValue extends Record<string, unknown>> = ReturnType<typeof object<TValue>>;
|
49
|
+
export {};
|
@@ -0,0 +1,57 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.object = void 0;
|
7
|
+
const is_plain_obj_1 = __importDefault(require("is-plain-obj"));
|
8
|
+
const core_1 = require("../core");
|
9
|
+
const optional_1 = require("../optional");
|
10
|
+
const isEmptyErrors_1 = require("./isEmptyErrors");
|
11
|
+
const constants_1 = require("./constants");
|
12
|
+
/**
|
13
|
+
* Guard для объекта
|
14
|
+
* @param schema - схема валидации объекта
|
15
|
+
* @example
|
16
|
+
* ```ts
|
17
|
+
* type Values = {
|
18
|
+
* name: string;
|
19
|
+
* age?: number;
|
20
|
+
* info: { surname: string };
|
21
|
+
* };
|
22
|
+
*
|
23
|
+
* const values: Values = { name: 'Vasya', info: { surname: 'Vasin' } };
|
24
|
+
*
|
25
|
+
* const validateObject = object<Values>({
|
26
|
+
* name: string(min(2)),
|
27
|
+
* age: optional(number()),
|
28
|
+
* info: object<Values['info']>({ surname: string(min(2)) }),
|
29
|
+
* customField: (value, ctx) => {
|
30
|
+
* return ctx.createError({ message: 'error', code: 'custom error' })
|
31
|
+
* }
|
32
|
+
* });
|
33
|
+
* ```
|
34
|
+
*/
|
35
|
+
const object = (schema) => (0, core_1.createGuard)((value, ctx, { typeErrorMessage, isPartial }) => {
|
36
|
+
const context = (0, core_1.createContext)(ctx, value, {
|
37
|
+
lastSchemaValue: value,
|
38
|
+
});
|
39
|
+
if (!(0, is_plain_obj_1.default)(value)) {
|
40
|
+
return context.createError(Object.assign(Object.assign({}, constants_1.OBJECT_TYPE_ERROR_INFO), { message: typeErrorMessage || constants_1.OBJECT_TYPE_ERROR_INFO.message }));
|
41
|
+
}
|
42
|
+
const generateErrorMap = () => {
|
43
|
+
const schemaEntries = Object.entries(schema);
|
44
|
+
const isOptional = context.global.overrides.objectIsPartial || isPartial;
|
45
|
+
return schemaEntries.reduce((errorMap, [key, rule]) => {
|
46
|
+
const callRule = isOptional ? (0, optional_1.optional)(rule) : rule;
|
47
|
+
errorMap[key] = (0, core_1.callRule)(callRule, value[key], context);
|
48
|
+
return errorMap;
|
49
|
+
}, {});
|
50
|
+
};
|
51
|
+
const errorMap = generateErrorMap();
|
52
|
+
if (!(0, isEmptyErrors_1.isEmptyErrors)(errorMap)) {
|
53
|
+
return (0, core_1.createErrorMap)(errorMap);
|
54
|
+
}
|
55
|
+
return undefined;
|
56
|
+
});
|
57
|
+
exports.object = object;
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './objectAsync';
|
@@ -0,0 +1,17 @@
|
|
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("./objectAsync"), exports);
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import { type AsyncGuard, type AsyncValidationRule, type Guard, type ValidationContext, type ValidationRule } from '../../core';
|
2
|
+
/**
|
3
|
+
* Специальный итерфейс Guard для object. В данном интерфейсе ctx required
|
4
|
+
* Переопределение необходимо для того, чтобы ts показывал, что ctx required в кастомных правилах
|
5
|
+
*/
|
6
|
+
interface ObjectPropGuard<TLastSchemaValues extends Record<string, unknown>> {
|
7
|
+
(value: Parameters<Guard<TLastSchemaValues>>[0], ctx: ValidationContext<TLastSchemaValues>): ReturnType<Guard<TLastSchemaValues>>;
|
8
|
+
define: Guard<TLastSchemaValues>['define'];
|
9
|
+
}
|
10
|
+
interface AsyncObjectPropGuard<TLastSchemaValues extends Record<string, unknown>> {
|
11
|
+
(value: Parameters<Guard<TLastSchemaValues>>[0], ctx: ValidationContext<TLastSchemaValues>): ReturnType<AsyncGuard<TLastSchemaValues>>;
|
12
|
+
define: AsyncGuard<TLastSchemaValues>['define'];
|
13
|
+
}
|
14
|
+
type AdditionalDefOptions = {
|
15
|
+
/**
|
16
|
+
* Делает все свойства объекта partial
|
17
|
+
*/
|
18
|
+
isPartial?: boolean;
|
19
|
+
};
|
20
|
+
/**
|
21
|
+
* Возможные значения, принимаемые схемой
|
22
|
+
*/
|
23
|
+
export type AsyncSchemaValue<TValue extends Record<string, unknown>> = ObjectPropGuard<TValue> | AsyncObjectPropGuard<TValue> | ValidationRule<unknown, TValue> | AsyncValidationRule<unknown, TValue>;
|
24
|
+
/**
|
25
|
+
* Схема правил валдиации для объекта
|
26
|
+
*/
|
27
|
+
export type AsyncSchema<TValue extends Record<string, unknown>> = Record<keyof TValue, AsyncSchemaValue<TValue>>;
|
28
|
+
/**
|
29
|
+
* Guard для объекта, который поддерживает асинхронную валидацию
|
30
|
+
* @example
|
31
|
+
* ```ts
|
32
|
+
* type Values = {
|
33
|
+
* name: string;
|
34
|
+
* age?: number;
|
35
|
+
* info: { surname: string };
|
36
|
+
* };
|
37
|
+
*
|
38
|
+
* const values: Values = { name: 'Vasya', info: { surname: 'Vasin' } };
|
39
|
+
*
|
40
|
+
* const validateObject = objectAsync<Values>({
|
41
|
+
* name: string(min(2), async (value, ctx) => {
|
42
|
+
* const result = await validateName(value);
|
43
|
+
*
|
44
|
+
* return result.isInvalid
|
45
|
+
* ? ctx.createError({
|
46
|
+
* message: 'Имя занято',
|
47
|
+
* code: 'name-is-not-available',
|
48
|
+
* })
|
49
|
+
* : undefined;
|
50
|
+
* }),
|
51
|
+
* age: optional(number()),
|
52
|
+
* info: object<Values['info']>({ surname: string(min(2)) }),
|
53
|
+
* customField: (value, ctx) => {
|
54
|
+
* return ctx.createError({ message: 'error', code: 'custom error' });
|
55
|
+
* },
|
56
|
+
* });
|
57
|
+
* ```
|
58
|
+
*/
|
59
|
+
export declare const objectAsync: <TValue extends Record<string, unknown>, TLastSchemaValues extends Record<string, unknown> = {}>(schema: AsyncSchema<TValue>) => AsyncGuard<TLastSchemaValues, AdditionalDefOptions>;
|
60
|
+
export type ObjectAsyncGuard<TValue extends Record<string, unknown>> = ReturnType<typeof objectAsync<TValue>>;
|
61
|
+
export {};
|