@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,71 @@
|
|
1
|
+
import { type ValidationResult } from '../../types';
|
2
|
+
import { type ValidationContext } from '../../context';
|
3
|
+
export type GuardDefOptions<AddDefOptions extends Record<string, unknown>> = Partial<AddDefOptions> & {
|
4
|
+
/**
|
5
|
+
* Переопределяет дефолтное сообщения ошибки для required
|
6
|
+
* @example string.define({ requiredMessage: 'ИНН не может быть пустым' })(inn())
|
7
|
+
*/
|
8
|
+
requiredErrorMessage?: string;
|
9
|
+
/**
|
10
|
+
* Переопределяет сообщение об ошибке типа
|
11
|
+
* @example string.define({ typeErrorMessage: 'ИНН не может быть числом' })(inn())
|
12
|
+
*/
|
13
|
+
typeErrorMessage?: string;
|
14
|
+
/**
|
15
|
+
* Позволяет выключать проверку на required
|
16
|
+
* @default false
|
17
|
+
*/
|
18
|
+
isOptional?: boolean;
|
19
|
+
};
|
20
|
+
export type GuardValue = unknown;
|
21
|
+
/**
|
22
|
+
* Интерфейс функции guard, которая в прототипе содержит метод define
|
23
|
+
*/
|
24
|
+
export interface Guard<TLastSchemaValues extends Record<string, unknown> = {}, AddDefOptions extends Record<string, unknown> = {}> {
|
25
|
+
(value: GuardValue, ctx?: ValidationContext<TLastSchemaValues>): ValidationResult;
|
26
|
+
/**
|
27
|
+
* Функция для создания нового guard с переопределенными дефолтными параметрами. Возвращает новый guard
|
28
|
+
* @param options - параметры, позволяющие переопределить дефолтные настройки guard
|
29
|
+
* @example string(inn()).define({ requiredMessage: 'ИНН не может быть пустым' })
|
30
|
+
*/
|
31
|
+
define<TDefineLastSchemaValues extends Record<string, unknown> = {}>(options: GuardDefOptions<AddDefOptions>): Guard<TDefineLastSchemaValues, AddDefOptions>;
|
32
|
+
}
|
33
|
+
/**
|
34
|
+
* Интерфейс асинхронной функции guard, которая в прототипе содержит метод define
|
35
|
+
*/
|
36
|
+
export interface AsyncGuard<TLastSchemaValues extends Record<string, unknown> = {}, AddDefOptions extends Record<string, unknown> = {}> {
|
37
|
+
(value: GuardValue, ctx?: ValidationContext<TLastSchemaValues>): Promise<ValidationResult>;
|
38
|
+
/**
|
39
|
+
* Функция для создания нового guard с переопределенными дефолтными параметрами. Возвращает новый guard
|
40
|
+
* @param options - параметры, позволяющие переопределить дефолтные настройки guard
|
41
|
+
* @example string.define({ requiredMessage: 'ИНН не может быть пустым' })(inn())
|
42
|
+
*/
|
43
|
+
define(options: GuardDefOptions<AddDefOptions>): AsyncGuard<TLastSchemaValues, AddDefOptions>;
|
44
|
+
}
|
45
|
+
/**
|
46
|
+
* Функция, которая позволяет определять частную логику для guard
|
47
|
+
*/
|
48
|
+
type GuardExecutor<TLastSchemaValues extends Record<string, unknown>, AddDefOptions extends Record<string, unknown>> = (value: unknown, ctx: ValidationContext<TLastSchemaValues>, defOptions: GuardDefOptions<AddDefOptions>) => ValidationResult;
|
49
|
+
/**
|
50
|
+
* Функция, которая позволяет определять частную логику для guard
|
51
|
+
*/
|
52
|
+
type AsyncGuardExecutor<TLastSchemaValues extends Record<string, unknown>, AddDefOptions extends Record<string, unknown>> = (value: unknown, ctx: ValidationContext<TLastSchemaValues>, defOptions: GuardDefOptions<AddDefOptions>) => Promise<ValidationResult>;
|
53
|
+
/**
|
54
|
+
* Создает guard. Guard - функция, проверяющая тип значения
|
55
|
+
* По-дефолту проверяет value на required. Для выключения required необходимо использовать optional().
|
56
|
+
* После первого вызова guard в прототипу функции становится доступен метод define, который позволяет переопределить дефолтное поведение guard (например, изменить текст для required правила)
|
57
|
+
* @example
|
58
|
+
* ```ts
|
59
|
+
* const string = <TLastSchemaValues extends Record<string, unknown>>(...rules: ValidationRule<string, TValues>[]) =>
|
60
|
+
* createGuard<string, TValues>((value, ctx) => {
|
61
|
+
* if (typeof value !== 'string') {
|
62
|
+
* return ctx.createError({ code: 'custom error', message: 'Не строка' });
|
63
|
+
* }
|
64
|
+
*
|
65
|
+
* return compose<string, TValues>(...rules)(value, ctx);
|
66
|
+
* });
|
67
|
+
* ```
|
68
|
+
*/
|
69
|
+
export declare function createGuard<TLastSchemaValues extends Record<string, unknown>, AddDefOptions extends Record<string, unknown> = {}>(executor: GuardExecutor<TLastSchemaValues, AddDefOptions>): Guard<TLastSchemaValues, AddDefOptions>;
|
70
|
+
export declare function createGuard<TLastSchemaValues extends Record<string, unknown>, AddDefOptions extends Record<string, unknown> = {}>(executor: AsyncGuardExecutor<TLastSchemaValues, AddDefOptions>): AsyncGuard<TLastSchemaValues, AddDefOptions>;
|
71
|
+
export {};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.createGuard = void 0;
|
4
|
+
const rule_1 = require("../../rule");
|
5
|
+
const context_1 = require("../../context");
|
6
|
+
function createGuard(executor) {
|
7
|
+
// выделено в отдельную именованную функцию для того, чтобы ее можно было рекурсивно вызывать в define
|
8
|
+
const createInnerGuard = (defOptions = {}) => {
|
9
|
+
const guard = (value, prevCtx) => {
|
10
|
+
const actualDefOptions = Object.assign(Object.assign({}, defOptions), { isOptional: (prevCtx === null || prevCtx === void 0 ? void 0 : prevCtx.isOptional) || defOptions.isOptional });
|
11
|
+
const ctx = (0, context_1.createContext)(prevCtx, value, {
|
12
|
+
// данная конструкция останавливает погружение isOptional в последующие guard
|
13
|
+
isOptional: false,
|
14
|
+
});
|
15
|
+
const requiredResult = (0, rule_1.required)({
|
16
|
+
message: actualDefOptions === null || actualDefOptions === void 0 ? void 0 : actualDefOptions.requiredErrorMessage,
|
17
|
+
})(value, ctx);
|
18
|
+
if ((actualDefOptions === null || actualDefOptions === void 0 ? void 0 : actualDefOptions.isOptional) && requiredResult) {
|
19
|
+
return undefined;
|
20
|
+
}
|
21
|
+
return requiredResult || executor(value, ctx, actualDefOptions);
|
22
|
+
};
|
23
|
+
guard.define = (overridesDefOptions) => createInnerGuard(overridesDefOptions);
|
24
|
+
return guard;
|
25
|
+
};
|
26
|
+
return createInnerGuard();
|
27
|
+
}
|
28
|
+
exports.createGuard = createGuard;
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './createGuard';
|
@@ -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("./createGuard"), exports);
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './createGuard';
|
@@ -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("./createGuard"), exports);
|
@@ -0,0 +1,25 @@
|
|
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("./types"), exports);
|
18
|
+
__exportStar(require("./errors"), exports);
|
19
|
+
__exportStar(require("./context"), exports);
|
20
|
+
__exportStar(require("./errors"), exports);
|
21
|
+
__exportStar(require("./guard"), exports);
|
22
|
+
__exportStar(require("./rule"), exports);
|
23
|
+
__exportStar(require("./compose"), exports);
|
24
|
+
__exportStar(require("./composeAsync"), exports);
|
25
|
+
__exportStar(require("./utils"), exports);
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './logger';
|
@@ -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("./logger"), exports);
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.logger = void 0;
|
4
|
+
class Logger {
|
5
|
+
constructor() {
|
6
|
+
this.packageName = '@astral/validations';
|
7
|
+
this.error = (message, err) => {
|
8
|
+
console.error(`${this.packageName}: ${message}`, err);
|
9
|
+
};
|
10
|
+
}
|
11
|
+
}
|
12
|
+
exports.logger = new Logger();
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { type AsyncValidationRule, type ValidationRule } from '../types';
|
2
|
+
import { type ValidationResult } from '../../types';
|
3
|
+
import { type ValidationContext } from '../../context';
|
4
|
+
/**
|
5
|
+
* Позволяет рекурсивно вызывать асинхронные правила. Rule может возвращать другой rule
|
6
|
+
* Если один из rule выбросит exception, то функция его обработает и вернет дефолтную ошибку
|
7
|
+
*/
|
8
|
+
export declare const callAsyncRule: <TValue, TLastSchemaValues extends Record<string, unknown>>(rule: ValidationRule<TValue, TLastSchemaValues> | AsyncValidationRule<TValue, TLastSchemaValues>, value: TValue, ctx: ValidationContext<TLastSchemaValues>) => ValidationResult | Promise<ValidationResult>;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.callAsyncRule = void 0;
|
4
|
+
const errors_1 = require("../../errors");
|
5
|
+
const logger_1 = require("../../logger");
|
6
|
+
/**
|
7
|
+
* Позволяет рекурсивно вызывать асинхронные правила. Rule может возвращать другой rule
|
8
|
+
* Если один из rule выбросит exception, то функция его обработает и вернет дефолтную ошибку
|
9
|
+
*/
|
10
|
+
const callAsyncRule = (rule, value, ctx) => {
|
11
|
+
const ruleResult = rule(value, ctx);
|
12
|
+
if (ruleResult && 'then' in ruleResult) {
|
13
|
+
return ruleResult
|
14
|
+
.then((result) => {
|
15
|
+
if (typeof result === 'function') {
|
16
|
+
return (0, exports.callAsyncRule)(result, value, ctx);
|
17
|
+
}
|
18
|
+
return result;
|
19
|
+
})
|
20
|
+
.catch((err) => {
|
21
|
+
logger_1.logger.error('Ошибка при выполнении асинхронного правила', err);
|
22
|
+
return ctx.createError(errors_1.REJECT_PROMISE_ERROR_INFO);
|
23
|
+
});
|
24
|
+
}
|
25
|
+
return typeof ruleResult === 'function'
|
26
|
+
? (0, exports.callAsyncRule)(ruleResult, value, ctx)
|
27
|
+
: ruleResult;
|
28
|
+
};
|
29
|
+
exports.callAsyncRule = callAsyncRule;
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './callAsyncRule';
|
@@ -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("./callAsyncRule"), exports);
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { type ValidationRule } from '../types';
|
2
|
+
import { type ValidationResult } from '../../types';
|
3
|
+
import { type ValidationContext } from '../../context';
|
4
|
+
/**
|
5
|
+
* Позволяет рекурсивно вызывать правила. Rule может возвращать другой rule
|
6
|
+
*/
|
7
|
+
export declare const callRule: <TValue, TLastSchemaValues extends Record<string, unknown>>(rule: ValidationRule<TValue, TLastSchemaValues>, value: TValue, ctx: ValidationContext<TLastSchemaValues>) => ValidationResult;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.callRule = void 0;
|
4
|
+
/**
|
5
|
+
* Позволяет рекурсивно вызывать правила. Rule может возвращать другой rule
|
6
|
+
*/
|
7
|
+
const callRule = (rule, value, ctx) => {
|
8
|
+
const ruleResult = rule(value, ctx);
|
9
|
+
return typeof ruleResult === 'function'
|
10
|
+
? (0, exports.callRule)(ruleResult, value, ctx)
|
11
|
+
: ruleResult;
|
12
|
+
};
|
13
|
+
exports.callRule = callRule;
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './callRule';
|
@@ -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("./callRule"), exports);
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { type ValidationResult, type ValidationTypes } from '../../types';
|
2
|
+
import { type ValidationContext } from '../../context';
|
3
|
+
import { type IndependentValidationRule } from '../types';
|
4
|
+
/**
|
5
|
+
* Единые параметры для всех правил
|
6
|
+
*/
|
7
|
+
export type CommonRuleParams<ValidationType extends ValidationTypes> = {
|
8
|
+
/**
|
9
|
+
* Функция, позволяющая для каждого правила указать исключение
|
10
|
+
*/
|
11
|
+
exclude?: (value: ValidationType, ctx: ValidationContext) => boolean;
|
12
|
+
};
|
13
|
+
/**
|
14
|
+
* Функция, которая позволяет определять частную логику для guard
|
15
|
+
*/
|
16
|
+
type RuleExecutor<ValidationType extends ValidationTypes, TLastSchemaValues extends Record<string, unknown>> = (value: ValidationType, ctx: ValidationContext<TLastSchemaValues>) => ValidationResult;
|
17
|
+
/**
|
18
|
+
* Создает правила валидации, которые можно использовать внутри guard или по отдельности
|
19
|
+
* @param executor - функция, которая позволяет определять частную логику для guard
|
20
|
+
* @param commonParams - единые параметры для всех rule
|
21
|
+
* @example
|
22
|
+
* ```ts
|
23
|
+
* const inn = (params: CommonRuleParams<string> & { message?: string }) =>
|
24
|
+
* createRule<string>((value, ctx) => {
|
25
|
+
* if (!isInn(value)) {
|
26
|
+
* return ctx.createError({ code: 'custom error', message: params?.message || 'Неверный ИНН' });
|
27
|
+
* }
|
28
|
+
*
|
29
|
+
* return undefined;
|
30
|
+
* }, params);
|
31
|
+
* ```
|
32
|
+
*/
|
33
|
+
export declare const createRule: <ValidationType extends unknown, TLastSchemaValues extends Record<string, unknown> = {}>(executor: RuleExecutor<ValidationType, TLastSchemaValues>, commonParams?: CommonRuleParams<ValidationType>) => (value: Parameters<IndependentValidationRule<ValidationType, TLastSchemaValues>>[0], prevCtx?: Parameters<IndependentValidationRule<ValidationType, TLastSchemaValues>>[1]) => ReturnType<IndependentValidationRule<ValidationType, TLastSchemaValues>>;
|
34
|
+
export {};
|
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.createRule = void 0;
|
4
|
+
const context_1 = require("../../context");
|
5
|
+
/**
|
6
|
+
* Создает правила валидации, которые можно использовать внутри guard или по отдельности
|
7
|
+
* @param executor - функция, которая позволяет определять частную логику для guard
|
8
|
+
* @param commonParams - единые параметры для всех rule
|
9
|
+
* @example
|
10
|
+
* ```ts
|
11
|
+
* const inn = (params: CommonRuleParams<string> & { message?: string }) =>
|
12
|
+
* createRule<string>((value, ctx) => {
|
13
|
+
* if (!isInn(value)) {
|
14
|
+
* return ctx.createError({ code: 'custom error', message: params?.message || 'Неверный ИНН' });
|
15
|
+
* }
|
16
|
+
*
|
17
|
+
* return undefined;
|
18
|
+
* }, params);
|
19
|
+
* ```
|
20
|
+
*/
|
21
|
+
const createRule = (executor, commonParams) => (value, prevCtx) => {
|
22
|
+
var _a;
|
23
|
+
// контекст создается, если он не был создан раннее
|
24
|
+
const ctx = (0, context_1.createContext)(prevCtx, value);
|
25
|
+
// если value попало под исключения из правил, то дальше валидацию не продолжаем
|
26
|
+
if ((_a = commonParams === null || commonParams === void 0 ? void 0 : commonParams.exclude) === null || _a === void 0 ? void 0 : _a.call(commonParams, value, ctx)) {
|
27
|
+
return undefined;
|
28
|
+
}
|
29
|
+
return executor(value, ctx);
|
30
|
+
};
|
31
|
+
exports.createRule = createRule;
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './createRule';
|
@@ -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("./createRule"), exports);
|
@@ -0,0 +1,21 @@
|
|
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("./createRule"), exports);
|
18
|
+
__exportStar(require("./types"), exports);
|
19
|
+
__exportStar(require("./required"), exports);
|
20
|
+
__exportStar(require("./callRule"), exports);
|
21
|
+
__exportStar(require("./callAsyncRule"), exports);
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.REQUIRED_ERROR_INFO = void 0;
|
4
|
+
const errors_1 = require("../../errors");
|
5
|
+
exports.REQUIRED_ERROR_INFO = {
|
6
|
+
code: (0, errors_1.createErrorCode)('required'),
|
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("./required"), exports);
|
18
|
+
__exportStar(require("./constants"), exports);
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* Проверяет value на пустоту. Если значение пустое, то возвращает ошибку.
|
3
|
+
* Правило универсально для всех типов данных
|
4
|
+
*/
|
5
|
+
export declare const required: ({ message, }?: {
|
6
|
+
/**
|
7
|
+
* Кастомное сообщение ошибки
|
8
|
+
* @default Обязательно
|
9
|
+
*/
|
10
|
+
message?: string;
|
11
|
+
}) => (value: unknown, prevCtx?: import("../..").ValidationContext<{}> | undefined) => import("../..").ValidationResult;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.required = void 0;
|
4
|
+
const createRule_1 = require("../createRule");
|
5
|
+
const constants_1 = require("./constants");
|
6
|
+
/**
|
7
|
+
* Проверяет value на пустоту. Если значение пустое, то возвращает ошибку.
|
8
|
+
* Правило универсально для всех типов данных
|
9
|
+
*/
|
10
|
+
const required = ({ message, } = {}) => (0, createRule_1.createRule)((value, ctx) => {
|
11
|
+
const createRequiredError = () => ctx.createError(Object.assign(Object.assign({}, constants_1.REQUIRED_ERROR_INFO), { message: message || constants_1.REQUIRED_ERROR_INFO.message }));
|
12
|
+
if (value === null) {
|
13
|
+
return createRequiredError();
|
14
|
+
}
|
15
|
+
if (typeof value === 'object') {
|
16
|
+
return undefined;
|
17
|
+
}
|
18
|
+
if (typeof value === 'number' || typeof value === 'symbol') {
|
19
|
+
return undefined;
|
20
|
+
}
|
21
|
+
if (typeof value === 'string') {
|
22
|
+
return value.trim() ? undefined : createRequiredError();
|
23
|
+
}
|
24
|
+
if (typeof value === 'boolean') {
|
25
|
+
return value ? undefined : createRequiredError();
|
26
|
+
}
|
27
|
+
return createRequiredError();
|
28
|
+
});
|
29
|
+
exports.required = required;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { type ValidationContext } from '../context';
|
2
|
+
import { type ValidationResult } from '../types';
|
3
|
+
/**
|
4
|
+
* Самостоятельное правило для валидации. Может использоваться вне guard'ов
|
5
|
+
*/
|
6
|
+
export type IndependentValidationRule<TValue, TLastSchemaValues extends Record<string, unknown>> = (value: TValue, ctx?: ValidationContext<TLastSchemaValues>) => ValidationResult;
|
7
|
+
/**
|
8
|
+
* Самостоятельное асинхронное правило для валидации. Может использоваться вне guard'ов
|
9
|
+
*/
|
10
|
+
export type AsyncIndependentValidationRule<TValue, TLastSchemaValues extends Record<string, unknown>> = (value: TValue, ctx?: ValidationContext<TLastSchemaValues>) => Promise<ValidationResult>;
|
11
|
+
/**
|
12
|
+
* Правило для валидации, работающее исключительно с guard'ами
|
13
|
+
*/
|
14
|
+
export type ValidationRule<TValue, TLastSchemaValues extends Record<string, unknown> = {}> = (value: TValue, ctx: ValidationContext<TLastSchemaValues>) => ValidationResult | ValidationRule<TValue, TLastSchemaValues>;
|
15
|
+
/**
|
16
|
+
* Асинхронное правило для валидации, работающее исключительно с guard'ами
|
17
|
+
*/
|
18
|
+
export type AsyncValidationRule<TValue, TLastSchemaValues extends Record<string, unknown> = {}> = (value: TValue, ctx: ValidationContext<TLastSchemaValues>) => Promise<ValidationResult | AsyncValidationRule<TValue, TLastSchemaValues> | ValidationRule<TValue, TLastSchemaValues>>;
|
19
|
+
/**
|
20
|
+
* Композиционное правило валидации, умеющее работать с любыми значениями.
|
21
|
+
* В основном используется для композиционных правил, которые принимают rule, умеющие валидировать разные значения (optional, transform...)
|
22
|
+
*/
|
23
|
+
export type UniversalCompositionalValidationRule<TLastSchemaValues extends Record<string, unknown>> = ValidationRule<any, TLastSchemaValues>;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { type ValidationError } from './errors';
|
2
|
+
/**
|
3
|
+
* Результат работы валидации
|
4
|
+
*/
|
5
|
+
export type ValidationResult = ValidationError | undefined;
|
6
|
+
/**
|
7
|
+
* Доступные для валидации типы value
|
8
|
+
*/
|
9
|
+
export type ValidationTypes = unknown | object | string | number | Date | Array<unknown>;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export * from './isDateEarlier';
|
2
|
+
export * from './isFullNameValidCharacters';
|
3
|
+
export * from './isHasConsecutiveChars';
|
4
|
+
export * from './isNoDoubleZeroStart';
|
5
|
+
export * from './isStartsWithAndEndsWithLetter';
|
6
|
+
export * from './isStringOfZeros';
|
7
|
+
export * from './isValidFullNameLength';
|
8
|
+
export * from './resetTime';
|
@@ -0,0 +1,24 @@
|
|
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("./isDateEarlier"), exports);
|
18
|
+
__exportStar(require("./isFullNameValidCharacters"), exports);
|
19
|
+
__exportStar(require("./isHasConsecutiveChars"), exports);
|
20
|
+
__exportStar(require("./isNoDoubleZeroStart"), exports);
|
21
|
+
__exportStar(require("./isStartsWithAndEndsWithLetter"), exports);
|
22
|
+
__exportStar(require("./isStringOfZeros"), exports);
|
23
|
+
__exportStar(require("./isValidFullNameLength"), exports);
|
24
|
+
__exportStar(require("./resetTime"), exports);
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './isDateEarlier';
|