@dereekb/model 13.12.2 → 13.12.3
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/index.cjs.js +155 -0
- package/index.esm.js +155 -0
- package/package.json +2 -2
- package/src/lib/validator/date.d.ts +10 -0
- package/src/lib/validator/number.d.ts +32 -0
- package/src/lib/validator/phone.d.ts +33 -0
- package/src/lib/validator/point.d.ts +22 -0
- package/src/lib/validator/string.d.ts +29 -0
- package/src/lib/validator/unique.d.ts +7 -0
- package/src/lib/validator/url.d.ts +22 -0
package/index.cjs.js
CHANGED
|
@@ -2934,40 +2934,126 @@ function _ts_generator(thisArg, body) {
|
|
|
2934
2934
|
|
|
2935
2935
|
/**
|
|
2936
2936
|
* ArkType schema for a valid ISO 8601 day string (e.g., "2024-01-15").
|
|
2937
|
+
*
|
|
2938
|
+
* @dbxUtil
|
|
2939
|
+
* @dbxUtilCategory validator
|
|
2940
|
+
* @dbxUtilKind const
|
|
2941
|
+
* @dbxUtilTags validator, arktype, date, iso8601, day, string
|
|
2942
|
+
*
|
|
2943
|
+
* @example
|
|
2944
|
+
* ```ts
|
|
2945
|
+
* type({ startsOn: iso8601DayStringType });
|
|
2946
|
+
* ```
|
|
2937
2947
|
*/ var iso8601DayStringType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
2938
2948
|
return val != null && util.isISO8601DayString(val) || ctx.mustBe('a valid ISO 8601 day string');
|
|
2939
2949
|
});
|
|
2940
2950
|
|
|
2941
2951
|
/**
|
|
2942
2952
|
* A number greater than or equal to 0.
|
|
2953
|
+
*
|
|
2954
|
+
* @dbxUtil
|
|
2955
|
+
* @dbxUtilCategory validator
|
|
2956
|
+
* @dbxUtilKind const
|
|
2957
|
+
* @dbxUtilTags validator, arktype, number, non-negative
|
|
2958
|
+
* @dbxUtilRelated non-negative-integer
|
|
2959
|
+
*
|
|
2960
|
+
* @example
|
|
2961
|
+
* ```ts
|
|
2962
|
+
* type({ price: NON_NEGATIVE_NUMBER });
|
|
2963
|
+
* ```
|
|
2943
2964
|
*/ var NON_NEGATIVE_NUMBER = 'number >= 0';
|
|
2944
2965
|
/**
|
|
2945
2966
|
* A non-negative integer.
|
|
2967
|
+
*
|
|
2968
|
+
* @dbxUtil
|
|
2969
|
+
* @dbxUtilCategory validator
|
|
2970
|
+
* @dbxUtilKind const
|
|
2971
|
+
* @dbxUtilTags validator, arktype, number, non-negative, integer
|
|
2972
|
+
* @dbxUtilRelated non-negative-number
|
|
2973
|
+
*
|
|
2974
|
+
* @example
|
|
2975
|
+
* ```ts
|
|
2976
|
+
* type({ count: NON_NEGATIVE_INTEGER });
|
|
2977
|
+
* ```
|
|
2946
2978
|
*/ var NON_NEGATIVE_INTEGER = 'number.integer >= 0';
|
|
2947
2979
|
/**
|
|
2948
2980
|
* ArkType schema for a valid minute of the day (0-1439).
|
|
2981
|
+
*
|
|
2982
|
+
* @dbxUtil
|
|
2983
|
+
* @dbxUtilCategory validator
|
|
2984
|
+
* @dbxUtilKind const
|
|
2985
|
+
* @dbxUtilTags validator, arktype, number, minute-of-day, time
|
|
2986
|
+
*
|
|
2987
|
+
* @example
|
|
2988
|
+
* ```ts
|
|
2989
|
+
* type({ startMinute: minuteOfDayType });
|
|
2990
|
+
* ```
|
|
2949
2991
|
*/ var minuteOfDayType = arktype.type('number').narrow(function(val, ctx) {
|
|
2950
2992
|
return val != null && util.isMinuteOfDay(val) || ctx.mustBe('a valid minute of the day (0-1439)');
|
|
2951
2993
|
});
|
|
2952
2994
|
|
|
2953
2995
|
/**
|
|
2954
2996
|
* ArkType schema for a valid E.164 phone number without an extension.
|
|
2997
|
+
*
|
|
2998
|
+
* @dbxUtil
|
|
2999
|
+
* @dbxUtilCategory validator
|
|
3000
|
+
* @dbxUtilKind const
|
|
3001
|
+
* @dbxUtilTags validator, arktype, phone, e164, string
|
|
3002
|
+
* @dbxUtilRelated e164-phone-number-with-optional-extension-type, e164-phone-number-with-extension-type
|
|
3003
|
+
*
|
|
3004
|
+
* @example
|
|
3005
|
+
* ```ts
|
|
3006
|
+
* type({ phone: e164PhoneNumberType });
|
|
3007
|
+
* ```
|
|
2955
3008
|
*/ var e164PhoneNumberType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
2956
3009
|
return val != null && util.isE164PhoneNumber(val, false) || ctx.mustBe('a valid E.164 phone number without an extension');
|
|
2957
3010
|
});
|
|
2958
3011
|
/**
|
|
2959
3012
|
* ArkType schema for a valid E.164 phone number, optionally with an extension.
|
|
3013
|
+
*
|
|
3014
|
+
* @dbxUtil
|
|
3015
|
+
* @dbxUtilCategory validator
|
|
3016
|
+
* @dbxUtilKind const
|
|
3017
|
+
* @dbxUtilTags validator, arktype, phone, e164, extension, string
|
|
3018
|
+
* @dbxUtilRelated e164-phone-number-type, e164-phone-number-with-extension-type
|
|
3019
|
+
*
|
|
3020
|
+
* @example
|
|
3021
|
+
* ```ts
|
|
3022
|
+
* type({ phone: e164PhoneNumberWithOptionalExtensionType });
|
|
3023
|
+
* ```
|
|
2960
3024
|
*/ var e164PhoneNumberWithOptionalExtensionType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
2961
3025
|
return val != null && util.isE164PhoneNumber(val, true) || ctx.mustBe('a valid E.164 phone number');
|
|
2962
3026
|
});
|
|
2963
3027
|
/**
|
|
2964
3028
|
* ArkType schema for a valid E.164 phone number that includes an extension.
|
|
3029
|
+
*
|
|
3030
|
+
* @dbxUtil
|
|
3031
|
+
* @dbxUtilCategory validator
|
|
3032
|
+
* @dbxUtilKind const
|
|
3033
|
+
* @dbxUtilTags validator, arktype, phone, e164, extension, string
|
|
3034
|
+
* @dbxUtilRelated e164-phone-number-type, e164-phone-number-with-optional-extension-type
|
|
3035
|
+
*
|
|
3036
|
+
* @example
|
|
3037
|
+
* ```ts
|
|
3038
|
+
* type({ phone: e164PhoneNumberWithExtensionType });
|
|
3039
|
+
* ```
|
|
2965
3040
|
*/ var e164PhoneNumberWithExtensionType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
2966
3041
|
return val != null && util.isE164PhoneNumberWithExtension(val) || ctx.mustBe('a valid E.164 phone number with an extension');
|
|
2967
3042
|
});
|
|
2968
3043
|
|
|
2969
3044
|
/**
|
|
2970
3045
|
* ArkType schema for a valid {@link LatLngPoint} with lat in [-90, 90] and lng in [-180, 180].
|
|
3046
|
+
*
|
|
3047
|
+
* @dbxUtil
|
|
3048
|
+
* @dbxUtilCategory validator
|
|
3049
|
+
* @dbxUtilKind const
|
|
3050
|
+
* @dbxUtilTags validator, arktype, lat-lng, point, geo, coordinates
|
|
3051
|
+
* @dbxUtilRelated lat-lng-string-type
|
|
3052
|
+
*
|
|
3053
|
+
* @example
|
|
3054
|
+
* ```ts
|
|
3055
|
+
* type({ location: latLngPointType });
|
|
3056
|
+
* ```
|
|
2971
3057
|
*/ var latLngPointType = arktype.type({
|
|
2972
3058
|
lat: '-90 <= number <= 90',
|
|
2973
3059
|
lng: '-180 <= number <= 180'
|
|
@@ -2976,15 +3062,47 @@ function _ts_generator(thisArg, body) {
|
|
|
2976
3062
|
});
|
|
2977
3063
|
/**
|
|
2978
3064
|
* ArkType schema for a valid {@link LatLngString} (comma-separated lat/lng, e.g. "30.5,-96.3").
|
|
3065
|
+
*
|
|
3066
|
+
* @dbxUtil
|
|
3067
|
+
* @dbxUtilCategory validator
|
|
3068
|
+
* @dbxUtilKind const
|
|
3069
|
+
* @dbxUtilTags validator, arktype, lat-lng, geo, coordinates, string
|
|
3070
|
+
* @dbxUtilRelated lat-lng-point-type
|
|
3071
|
+
*
|
|
3072
|
+
* @example
|
|
3073
|
+
* ```ts
|
|
3074
|
+
* type({ location: latLngStringType });
|
|
3075
|
+
* ```
|
|
2979
3076
|
*/ var latLngStringType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
2980
3077
|
return val != null && util.isLatLngString(val) || ctx.mustBe('a valid lat,lng string (e.g. "30.5,-96.3")');
|
|
2981
3078
|
});
|
|
2982
3079
|
|
|
2983
3080
|
/**
|
|
2984
3081
|
* A string with at least one character (non-empty).
|
|
3082
|
+
*
|
|
3083
|
+
* @dbxUtil
|
|
3084
|
+
* @dbxUtilCategory validator
|
|
3085
|
+
* @dbxUtilKind const
|
|
3086
|
+
* @dbxUtilTags validator, arktype, string, non-empty, required
|
|
3087
|
+
* @dbxUtilRelated email-string, non-empty-string-with-max-length
|
|
3088
|
+
*
|
|
3089
|
+
* @example
|
|
3090
|
+
* ```ts
|
|
3091
|
+
* type({ name: NON_EMPTY_STRING });
|
|
3092
|
+
* ```
|
|
2985
3093
|
*/ var NON_EMPTY_STRING = 'string > 0';
|
|
2986
3094
|
/**
|
|
2987
3095
|
* A valid email address string.
|
|
3096
|
+
*
|
|
3097
|
+
* @dbxUtil
|
|
3098
|
+
* @dbxUtilCategory validator
|
|
3099
|
+
* @dbxUtilKind const
|
|
3100
|
+
* @dbxUtilTags validator, arktype, string, email
|
|
3101
|
+
*
|
|
3102
|
+
* @example
|
|
3103
|
+
* ```ts
|
|
3104
|
+
* type({ email: EMAIL_STRING });
|
|
3105
|
+
* ```
|
|
2988
3106
|
*/ var EMAIL_STRING = 'string.email';
|
|
2989
3107
|
/**
|
|
2990
3108
|
* Creates an ArkType string definition for a non-empty string with a maximum length.
|
|
@@ -2995,12 +3113,20 @@ function _ts_generator(thisArg, body) {
|
|
|
2995
3113
|
* @param maxLength - The maximum number of characters allowed (inclusive).
|
|
2996
3114
|
* @returns The ArkType string definition.
|
|
2997
3115
|
*
|
|
3116
|
+
* @dbxUtil
|
|
3117
|
+
* @dbxUtilCategory validator
|
|
3118
|
+
* @dbxUtilKind factory
|
|
3119
|
+
* @dbxUtilTags validator, arktype, string, non-empty, max-length, bounded
|
|
3120
|
+
* @dbxUtilRelated non-empty-string
|
|
3121
|
+
*
|
|
2998
3122
|
* @example
|
|
2999
3123
|
* ```ts
|
|
3000
3124
|
* const userType = type({
|
|
3001
3125
|
* displayName: nonEmptyStringWithMaxLength(64)
|
|
3002
3126
|
* });
|
|
3003
3127
|
* ```
|
|
3128
|
+
*
|
|
3129
|
+
* @__NO_SIDE_EFFECTS__
|
|
3004
3130
|
*/ function nonEmptyStringWithMaxLength(maxLength) {
|
|
3005
3131
|
return "".concat(NON_EMPTY_STRING, " & string <= ").concat(maxLength);
|
|
3006
3132
|
}
|
|
@@ -3011,10 +3137,17 @@ function _ts_generator(thisArg, body) {
|
|
|
3011
3137
|
* @param readKey - Function that extracts the key from each array element.
|
|
3012
3138
|
* @returns An ArkType schema that narrows `T[]` to ensure uniqueness.
|
|
3013
3139
|
*
|
|
3140
|
+
* @dbxUtil
|
|
3141
|
+
* @dbxUtilCategory validator
|
|
3142
|
+
* @dbxUtilKind factory
|
|
3143
|
+
* @dbxUtilTags validator, arktype, array, unique, uniqueness, keyed
|
|
3144
|
+
*
|
|
3014
3145
|
* @example
|
|
3015
3146
|
* ```typescript
|
|
3016
3147
|
* const uniqueItemsType = uniqueKeyedType((item: Item) => item.id);
|
|
3017
3148
|
* ```
|
|
3149
|
+
*
|
|
3150
|
+
* @__NO_SIDE_EFFECTS__
|
|
3018
3151
|
*/ function uniqueKeyedType(readKey) {
|
|
3019
3152
|
var isUniqueKeyed = util.isUniqueKeyedFunction(readKey);
|
|
3020
3153
|
return arktype.type('unknown[]').narrow(function(val, ctx) {
|
|
@@ -3024,11 +3157,33 @@ function _ts_generator(thisArg, body) {
|
|
|
3024
3157
|
|
|
3025
3158
|
/**
|
|
3026
3159
|
* ArkType schema for a valid website URL (with or without protocol prefix).
|
|
3160
|
+
*
|
|
3161
|
+
* @dbxUtil
|
|
3162
|
+
* @dbxUtilCategory validator
|
|
3163
|
+
* @dbxUtilKind const
|
|
3164
|
+
* @dbxUtilTags validator, arktype, url, website, string
|
|
3165
|
+
* @dbxUtilRelated website-url-with-prefix-type
|
|
3166
|
+
*
|
|
3167
|
+
* @example
|
|
3168
|
+
* ```ts
|
|
3169
|
+
* type({ website: websiteUrlType });
|
|
3170
|
+
* ```
|
|
3027
3171
|
*/ var websiteUrlType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
3028
3172
|
return val != null && util.isWebsiteUrl(val) || ctx.mustBe('a valid website URL');
|
|
3029
3173
|
});
|
|
3030
3174
|
/**
|
|
3031
3175
|
* ArkType schema for a valid website URL that starts with `http://` or `https://`.
|
|
3176
|
+
*
|
|
3177
|
+
* @dbxUtil
|
|
3178
|
+
* @dbxUtilCategory validator
|
|
3179
|
+
* @dbxUtilKind const
|
|
3180
|
+
* @dbxUtilTags validator, arktype, url, website, prefix, https, string
|
|
3181
|
+
* @dbxUtilRelated website-url-type
|
|
3182
|
+
*
|
|
3183
|
+
* @example
|
|
3184
|
+
* ```ts
|
|
3185
|
+
* type({ website: websiteUrlWithPrefixType });
|
|
3186
|
+
* ```
|
|
3032
3187
|
*/ var websiteUrlWithPrefixType = arktype.type('string > 0').narrow(function(val, ctx) {
|
|
3033
3188
|
return val != null && util.isWebsiteUrlWithPrefix(val) || ctx.mustBe('a valid website URL starting with http:// or https://');
|
|
3034
3189
|
});
|
package/index.esm.js
CHANGED
|
@@ -2932,40 +2932,126 @@ function _ts_generator(thisArg, body) {
|
|
|
2932
2932
|
|
|
2933
2933
|
/**
|
|
2934
2934
|
* ArkType schema for a valid ISO 8601 day string (e.g., "2024-01-15").
|
|
2935
|
+
*
|
|
2936
|
+
* @dbxUtil
|
|
2937
|
+
* @dbxUtilCategory validator
|
|
2938
|
+
* @dbxUtilKind const
|
|
2939
|
+
* @dbxUtilTags validator, arktype, date, iso8601, day, string
|
|
2940
|
+
*
|
|
2941
|
+
* @example
|
|
2942
|
+
* ```ts
|
|
2943
|
+
* type({ startsOn: iso8601DayStringType });
|
|
2944
|
+
* ```
|
|
2935
2945
|
*/ var iso8601DayStringType = type('string > 0').narrow(function(val, ctx) {
|
|
2936
2946
|
return val != null && isISO8601DayString(val) || ctx.mustBe('a valid ISO 8601 day string');
|
|
2937
2947
|
});
|
|
2938
2948
|
|
|
2939
2949
|
/**
|
|
2940
2950
|
* A number greater than or equal to 0.
|
|
2951
|
+
*
|
|
2952
|
+
* @dbxUtil
|
|
2953
|
+
* @dbxUtilCategory validator
|
|
2954
|
+
* @dbxUtilKind const
|
|
2955
|
+
* @dbxUtilTags validator, arktype, number, non-negative
|
|
2956
|
+
* @dbxUtilRelated non-negative-integer
|
|
2957
|
+
*
|
|
2958
|
+
* @example
|
|
2959
|
+
* ```ts
|
|
2960
|
+
* type({ price: NON_NEGATIVE_NUMBER });
|
|
2961
|
+
* ```
|
|
2941
2962
|
*/ var NON_NEGATIVE_NUMBER = 'number >= 0';
|
|
2942
2963
|
/**
|
|
2943
2964
|
* A non-negative integer.
|
|
2965
|
+
*
|
|
2966
|
+
* @dbxUtil
|
|
2967
|
+
* @dbxUtilCategory validator
|
|
2968
|
+
* @dbxUtilKind const
|
|
2969
|
+
* @dbxUtilTags validator, arktype, number, non-negative, integer
|
|
2970
|
+
* @dbxUtilRelated non-negative-number
|
|
2971
|
+
*
|
|
2972
|
+
* @example
|
|
2973
|
+
* ```ts
|
|
2974
|
+
* type({ count: NON_NEGATIVE_INTEGER });
|
|
2975
|
+
* ```
|
|
2944
2976
|
*/ var NON_NEGATIVE_INTEGER = 'number.integer >= 0';
|
|
2945
2977
|
/**
|
|
2946
2978
|
* ArkType schema for a valid minute of the day (0-1439).
|
|
2979
|
+
*
|
|
2980
|
+
* @dbxUtil
|
|
2981
|
+
* @dbxUtilCategory validator
|
|
2982
|
+
* @dbxUtilKind const
|
|
2983
|
+
* @dbxUtilTags validator, arktype, number, minute-of-day, time
|
|
2984
|
+
*
|
|
2985
|
+
* @example
|
|
2986
|
+
* ```ts
|
|
2987
|
+
* type({ startMinute: minuteOfDayType });
|
|
2988
|
+
* ```
|
|
2947
2989
|
*/ var minuteOfDayType = type('number').narrow(function(val, ctx) {
|
|
2948
2990
|
return val != null && isMinuteOfDay(val) || ctx.mustBe('a valid minute of the day (0-1439)');
|
|
2949
2991
|
});
|
|
2950
2992
|
|
|
2951
2993
|
/**
|
|
2952
2994
|
* ArkType schema for a valid E.164 phone number without an extension.
|
|
2995
|
+
*
|
|
2996
|
+
* @dbxUtil
|
|
2997
|
+
* @dbxUtilCategory validator
|
|
2998
|
+
* @dbxUtilKind const
|
|
2999
|
+
* @dbxUtilTags validator, arktype, phone, e164, string
|
|
3000
|
+
* @dbxUtilRelated e164-phone-number-with-optional-extension-type, e164-phone-number-with-extension-type
|
|
3001
|
+
*
|
|
3002
|
+
* @example
|
|
3003
|
+
* ```ts
|
|
3004
|
+
* type({ phone: e164PhoneNumberType });
|
|
3005
|
+
* ```
|
|
2953
3006
|
*/ var e164PhoneNumberType = type('string > 0').narrow(function(val, ctx) {
|
|
2954
3007
|
return val != null && isE164PhoneNumber(val, false) || ctx.mustBe('a valid E.164 phone number without an extension');
|
|
2955
3008
|
});
|
|
2956
3009
|
/**
|
|
2957
3010
|
* ArkType schema for a valid E.164 phone number, optionally with an extension.
|
|
3011
|
+
*
|
|
3012
|
+
* @dbxUtil
|
|
3013
|
+
* @dbxUtilCategory validator
|
|
3014
|
+
* @dbxUtilKind const
|
|
3015
|
+
* @dbxUtilTags validator, arktype, phone, e164, extension, string
|
|
3016
|
+
* @dbxUtilRelated e164-phone-number-type, e164-phone-number-with-extension-type
|
|
3017
|
+
*
|
|
3018
|
+
* @example
|
|
3019
|
+
* ```ts
|
|
3020
|
+
* type({ phone: e164PhoneNumberWithOptionalExtensionType });
|
|
3021
|
+
* ```
|
|
2958
3022
|
*/ var e164PhoneNumberWithOptionalExtensionType = type('string > 0').narrow(function(val, ctx) {
|
|
2959
3023
|
return val != null && isE164PhoneNumber(val, true) || ctx.mustBe('a valid E.164 phone number');
|
|
2960
3024
|
});
|
|
2961
3025
|
/**
|
|
2962
3026
|
* ArkType schema for a valid E.164 phone number that includes an extension.
|
|
3027
|
+
*
|
|
3028
|
+
* @dbxUtil
|
|
3029
|
+
* @dbxUtilCategory validator
|
|
3030
|
+
* @dbxUtilKind const
|
|
3031
|
+
* @dbxUtilTags validator, arktype, phone, e164, extension, string
|
|
3032
|
+
* @dbxUtilRelated e164-phone-number-type, e164-phone-number-with-optional-extension-type
|
|
3033
|
+
*
|
|
3034
|
+
* @example
|
|
3035
|
+
* ```ts
|
|
3036
|
+
* type({ phone: e164PhoneNumberWithExtensionType });
|
|
3037
|
+
* ```
|
|
2963
3038
|
*/ var e164PhoneNumberWithExtensionType = type('string > 0').narrow(function(val, ctx) {
|
|
2964
3039
|
return val != null && isE164PhoneNumberWithExtension(val) || ctx.mustBe('a valid E.164 phone number with an extension');
|
|
2965
3040
|
});
|
|
2966
3041
|
|
|
2967
3042
|
/**
|
|
2968
3043
|
* ArkType schema for a valid {@link LatLngPoint} with lat in [-90, 90] and lng in [-180, 180].
|
|
3044
|
+
*
|
|
3045
|
+
* @dbxUtil
|
|
3046
|
+
* @dbxUtilCategory validator
|
|
3047
|
+
* @dbxUtilKind const
|
|
3048
|
+
* @dbxUtilTags validator, arktype, lat-lng, point, geo, coordinates
|
|
3049
|
+
* @dbxUtilRelated lat-lng-string-type
|
|
3050
|
+
*
|
|
3051
|
+
* @example
|
|
3052
|
+
* ```ts
|
|
3053
|
+
* type({ location: latLngPointType });
|
|
3054
|
+
* ```
|
|
2969
3055
|
*/ var latLngPointType = type({
|
|
2970
3056
|
lat: '-90 <= number <= 90',
|
|
2971
3057
|
lng: '-180 <= number <= 180'
|
|
@@ -2974,15 +3060,47 @@ function _ts_generator(thisArg, body) {
|
|
|
2974
3060
|
});
|
|
2975
3061
|
/**
|
|
2976
3062
|
* ArkType schema for a valid {@link LatLngString} (comma-separated lat/lng, e.g. "30.5,-96.3").
|
|
3063
|
+
*
|
|
3064
|
+
* @dbxUtil
|
|
3065
|
+
* @dbxUtilCategory validator
|
|
3066
|
+
* @dbxUtilKind const
|
|
3067
|
+
* @dbxUtilTags validator, arktype, lat-lng, geo, coordinates, string
|
|
3068
|
+
* @dbxUtilRelated lat-lng-point-type
|
|
3069
|
+
*
|
|
3070
|
+
* @example
|
|
3071
|
+
* ```ts
|
|
3072
|
+
* type({ location: latLngStringType });
|
|
3073
|
+
* ```
|
|
2977
3074
|
*/ var latLngStringType = type('string > 0').narrow(function(val, ctx) {
|
|
2978
3075
|
return val != null && isLatLngString(val) || ctx.mustBe('a valid lat,lng string (e.g. "30.5,-96.3")');
|
|
2979
3076
|
});
|
|
2980
3077
|
|
|
2981
3078
|
/**
|
|
2982
3079
|
* A string with at least one character (non-empty).
|
|
3080
|
+
*
|
|
3081
|
+
* @dbxUtil
|
|
3082
|
+
* @dbxUtilCategory validator
|
|
3083
|
+
* @dbxUtilKind const
|
|
3084
|
+
* @dbxUtilTags validator, arktype, string, non-empty, required
|
|
3085
|
+
* @dbxUtilRelated email-string, non-empty-string-with-max-length
|
|
3086
|
+
*
|
|
3087
|
+
* @example
|
|
3088
|
+
* ```ts
|
|
3089
|
+
* type({ name: NON_EMPTY_STRING });
|
|
3090
|
+
* ```
|
|
2983
3091
|
*/ var NON_EMPTY_STRING = 'string > 0';
|
|
2984
3092
|
/**
|
|
2985
3093
|
* A valid email address string.
|
|
3094
|
+
*
|
|
3095
|
+
* @dbxUtil
|
|
3096
|
+
* @dbxUtilCategory validator
|
|
3097
|
+
* @dbxUtilKind const
|
|
3098
|
+
* @dbxUtilTags validator, arktype, string, email
|
|
3099
|
+
*
|
|
3100
|
+
* @example
|
|
3101
|
+
* ```ts
|
|
3102
|
+
* type({ email: EMAIL_STRING });
|
|
3103
|
+
* ```
|
|
2986
3104
|
*/ var EMAIL_STRING = 'string.email';
|
|
2987
3105
|
/**
|
|
2988
3106
|
* Creates an ArkType string definition for a non-empty string with a maximum length.
|
|
@@ -2993,12 +3111,20 @@ function _ts_generator(thisArg, body) {
|
|
|
2993
3111
|
* @param maxLength - The maximum number of characters allowed (inclusive).
|
|
2994
3112
|
* @returns The ArkType string definition.
|
|
2995
3113
|
*
|
|
3114
|
+
* @dbxUtil
|
|
3115
|
+
* @dbxUtilCategory validator
|
|
3116
|
+
* @dbxUtilKind factory
|
|
3117
|
+
* @dbxUtilTags validator, arktype, string, non-empty, max-length, bounded
|
|
3118
|
+
* @dbxUtilRelated non-empty-string
|
|
3119
|
+
*
|
|
2996
3120
|
* @example
|
|
2997
3121
|
* ```ts
|
|
2998
3122
|
* const userType = type({
|
|
2999
3123
|
* displayName: nonEmptyStringWithMaxLength(64)
|
|
3000
3124
|
* });
|
|
3001
3125
|
* ```
|
|
3126
|
+
*
|
|
3127
|
+
* @__NO_SIDE_EFFECTS__
|
|
3002
3128
|
*/ function nonEmptyStringWithMaxLength(maxLength) {
|
|
3003
3129
|
return "".concat(NON_EMPTY_STRING, " & string <= ").concat(maxLength);
|
|
3004
3130
|
}
|
|
@@ -3009,10 +3135,17 @@ function _ts_generator(thisArg, body) {
|
|
|
3009
3135
|
* @param readKey - Function that extracts the key from each array element.
|
|
3010
3136
|
* @returns An ArkType schema that narrows `T[]` to ensure uniqueness.
|
|
3011
3137
|
*
|
|
3138
|
+
* @dbxUtil
|
|
3139
|
+
* @dbxUtilCategory validator
|
|
3140
|
+
* @dbxUtilKind factory
|
|
3141
|
+
* @dbxUtilTags validator, arktype, array, unique, uniqueness, keyed
|
|
3142
|
+
*
|
|
3012
3143
|
* @example
|
|
3013
3144
|
* ```typescript
|
|
3014
3145
|
* const uniqueItemsType = uniqueKeyedType((item: Item) => item.id);
|
|
3015
3146
|
* ```
|
|
3147
|
+
*
|
|
3148
|
+
* @__NO_SIDE_EFFECTS__
|
|
3016
3149
|
*/ function uniqueKeyedType(readKey) {
|
|
3017
3150
|
var isUniqueKeyed = isUniqueKeyedFunction(readKey);
|
|
3018
3151
|
return type('unknown[]').narrow(function(val, ctx) {
|
|
@@ -3022,11 +3155,33 @@ function _ts_generator(thisArg, body) {
|
|
|
3022
3155
|
|
|
3023
3156
|
/**
|
|
3024
3157
|
* ArkType schema for a valid website URL (with or without protocol prefix).
|
|
3158
|
+
*
|
|
3159
|
+
* @dbxUtil
|
|
3160
|
+
* @dbxUtilCategory validator
|
|
3161
|
+
* @dbxUtilKind const
|
|
3162
|
+
* @dbxUtilTags validator, arktype, url, website, string
|
|
3163
|
+
* @dbxUtilRelated website-url-with-prefix-type
|
|
3164
|
+
*
|
|
3165
|
+
* @example
|
|
3166
|
+
* ```ts
|
|
3167
|
+
* type({ website: websiteUrlType });
|
|
3168
|
+
* ```
|
|
3025
3169
|
*/ var websiteUrlType = type('string > 0').narrow(function(val, ctx) {
|
|
3026
3170
|
return val != null && isWebsiteUrl(val) || ctx.mustBe('a valid website URL');
|
|
3027
3171
|
});
|
|
3028
3172
|
/**
|
|
3029
3173
|
* ArkType schema for a valid website URL that starts with `http://` or `https://`.
|
|
3174
|
+
*
|
|
3175
|
+
* @dbxUtil
|
|
3176
|
+
* @dbxUtilCategory validator
|
|
3177
|
+
* @dbxUtilKind const
|
|
3178
|
+
* @dbxUtilTags validator, arktype, url, website, prefix, https, string
|
|
3179
|
+
* @dbxUtilRelated website-url-type
|
|
3180
|
+
*
|
|
3181
|
+
* @example
|
|
3182
|
+
* ```ts
|
|
3183
|
+
* type({ website: websiteUrlWithPrefixType });
|
|
3184
|
+
* ```
|
|
3030
3185
|
*/ var websiteUrlWithPrefixType = type('string > 0').narrow(function(val, ctx) {
|
|
3031
3186
|
return val != null && isWebsiteUrlWithPrefix(val) || ctx.mustBe('a valid website URL starting with http:// or https://');
|
|
3032
3187
|
});
|
package/package.json
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ArkType schema for a valid ISO 8601 day string (e.g., "2024-01-15").
|
|
3
|
+
*
|
|
4
|
+
* @dbxUtil
|
|
5
|
+
* @dbxUtilCategory validator
|
|
6
|
+
* @dbxUtilKind const
|
|
7
|
+
* @dbxUtilTags validator, arktype, date, iso8601, day, string
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* type({ startsOn: iso8601DayStringType });
|
|
12
|
+
* ```
|
|
3
13
|
*/
|
|
4
14
|
export declare const iso8601DayStringType: import("arktype/internal/variants/string.ts").StringType<string, {}>;
|
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A number greater than or equal to 0.
|
|
3
|
+
*
|
|
4
|
+
* @dbxUtil
|
|
5
|
+
* @dbxUtilCategory validator
|
|
6
|
+
* @dbxUtilKind const
|
|
7
|
+
* @dbxUtilTags validator, arktype, number, non-negative
|
|
8
|
+
* @dbxUtilRelated non-negative-integer
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* type({ price: NON_NEGATIVE_NUMBER });
|
|
13
|
+
* ```
|
|
3
14
|
*/
|
|
4
15
|
export declare const NON_NEGATIVE_NUMBER: "number >= 0";
|
|
5
16
|
/**
|
|
6
17
|
* A non-negative integer.
|
|
18
|
+
*
|
|
19
|
+
* @dbxUtil
|
|
20
|
+
* @dbxUtilCategory validator
|
|
21
|
+
* @dbxUtilKind const
|
|
22
|
+
* @dbxUtilTags validator, arktype, number, non-negative, integer
|
|
23
|
+
* @dbxUtilRelated non-negative-number
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* type({ count: NON_NEGATIVE_INTEGER });
|
|
28
|
+
* ```
|
|
7
29
|
*/
|
|
8
30
|
export declare const NON_NEGATIVE_INTEGER: "number.integer >= 0";
|
|
9
31
|
/**
|
|
10
32
|
* ArkType schema for a valid minute of the day (0-1439).
|
|
33
|
+
*
|
|
34
|
+
* @dbxUtil
|
|
35
|
+
* @dbxUtilCategory validator
|
|
36
|
+
* @dbxUtilKind const
|
|
37
|
+
* @dbxUtilTags validator, arktype, number, minute-of-day, time
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* type({ startMinute: minuteOfDayType });
|
|
42
|
+
* ```
|
|
11
43
|
*/
|
|
12
44
|
export declare const minuteOfDayType: import("arktype/internal/variants/number.ts").NumberType<number, {}>;
|
|
@@ -1,12 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ArkType schema for a valid E.164 phone number without an extension.
|
|
3
|
+
*
|
|
4
|
+
* @dbxUtil
|
|
5
|
+
* @dbxUtilCategory validator
|
|
6
|
+
* @dbxUtilKind const
|
|
7
|
+
* @dbxUtilTags validator, arktype, phone, e164, string
|
|
8
|
+
* @dbxUtilRelated e164-phone-number-with-optional-extension-type, e164-phone-number-with-extension-type
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* type({ phone: e164PhoneNumberType });
|
|
13
|
+
* ```
|
|
3
14
|
*/
|
|
4
15
|
export declare const e164PhoneNumberType: import("arktype/internal/variants/string.ts").StringType<string, {}>;
|
|
5
16
|
/**
|
|
6
17
|
* ArkType schema for a valid E.164 phone number, optionally with an extension.
|
|
18
|
+
*
|
|
19
|
+
* @dbxUtil
|
|
20
|
+
* @dbxUtilCategory validator
|
|
21
|
+
* @dbxUtilKind const
|
|
22
|
+
* @dbxUtilTags validator, arktype, phone, e164, extension, string
|
|
23
|
+
* @dbxUtilRelated e164-phone-number-type, e164-phone-number-with-extension-type
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* type({ phone: e164PhoneNumberWithOptionalExtensionType });
|
|
28
|
+
* ```
|
|
7
29
|
*/
|
|
8
30
|
export declare const e164PhoneNumberWithOptionalExtensionType: import("arktype/internal/variants/string.ts").StringType<string, {}>;
|
|
9
31
|
/**
|
|
10
32
|
* ArkType schema for a valid E.164 phone number that includes an extension.
|
|
33
|
+
*
|
|
34
|
+
* @dbxUtil
|
|
35
|
+
* @dbxUtilCategory validator
|
|
36
|
+
* @dbxUtilKind const
|
|
37
|
+
* @dbxUtilTags validator, arktype, phone, e164, extension, string
|
|
38
|
+
* @dbxUtilRelated e164-phone-number-type, e164-phone-number-with-optional-extension-type
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* type({ phone: e164PhoneNumberWithExtensionType });
|
|
43
|
+
* ```
|
|
11
44
|
*/
|
|
12
45
|
export declare const e164PhoneNumberWithExtensionType: import("arktype/internal/variants/string.ts").StringType<string, {}>;
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ArkType schema for a valid {@link LatLngPoint} with lat in [-90, 90] and lng in [-180, 180].
|
|
3
|
+
*
|
|
4
|
+
* @dbxUtil
|
|
5
|
+
* @dbxUtilCategory validator
|
|
6
|
+
* @dbxUtilKind const
|
|
7
|
+
* @dbxUtilTags validator, arktype, lat-lng, point, geo, coordinates
|
|
8
|
+
* @dbxUtilRelated lat-lng-string-type
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* type({ location: latLngPointType });
|
|
13
|
+
* ```
|
|
3
14
|
*/
|
|
4
15
|
export declare const latLngPointType: import("arktype/internal/variants/object.ts").ObjectType<{
|
|
5
16
|
lat: number;
|
|
@@ -7,5 +18,16 @@ export declare const latLngPointType: import("arktype/internal/variants/object.t
|
|
|
7
18
|
}, {}>;
|
|
8
19
|
/**
|
|
9
20
|
* ArkType schema for a valid {@link LatLngString} (comma-separated lat/lng, e.g. "30.5,-96.3").
|
|
21
|
+
*
|
|
22
|
+
* @dbxUtil
|
|
23
|
+
* @dbxUtilCategory validator
|
|
24
|
+
* @dbxUtilKind const
|
|
25
|
+
* @dbxUtilTags validator, arktype, lat-lng, geo, coordinates, string
|
|
26
|
+
* @dbxUtilRelated lat-lng-point-type
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* type({ location: latLngStringType });
|
|
31
|
+
* ```
|
|
10
32
|
*/
|
|
11
33
|
export declare const latLngStringType: import("arktype/internal/variants/string.ts").StringType<string, {}>;
|
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A string with at least one character (non-empty).
|
|
3
|
+
*
|
|
4
|
+
* @dbxUtil
|
|
5
|
+
* @dbxUtilCategory validator
|
|
6
|
+
* @dbxUtilKind const
|
|
7
|
+
* @dbxUtilTags validator, arktype, string, non-empty, required
|
|
8
|
+
* @dbxUtilRelated email-string, non-empty-string-with-max-length
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* type({ name: NON_EMPTY_STRING });
|
|
13
|
+
* ```
|
|
3
14
|
*/
|
|
4
15
|
export declare const NON_EMPTY_STRING: "string > 0";
|
|
5
16
|
/**
|
|
6
17
|
* A valid email address string.
|
|
18
|
+
*
|
|
19
|
+
* @dbxUtil
|
|
20
|
+
* @dbxUtilCategory validator
|
|
21
|
+
* @dbxUtilKind const
|
|
22
|
+
* @dbxUtilTags validator, arktype, string, email
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* type({ email: EMAIL_STRING });
|
|
27
|
+
* ```
|
|
7
28
|
*/
|
|
8
29
|
export declare const EMAIL_STRING: "string.email";
|
|
9
30
|
/**
|
|
@@ -15,11 +36,19 @@ export declare const EMAIL_STRING: "string.email";
|
|
|
15
36
|
* @param maxLength - The maximum number of characters allowed (inclusive).
|
|
16
37
|
* @returns The ArkType string definition.
|
|
17
38
|
*
|
|
39
|
+
* @dbxUtil
|
|
40
|
+
* @dbxUtilCategory validator
|
|
41
|
+
* @dbxUtilKind factory
|
|
42
|
+
* @dbxUtilTags validator, arktype, string, non-empty, max-length, bounded
|
|
43
|
+
* @dbxUtilRelated non-empty-string
|
|
44
|
+
*
|
|
18
45
|
* @example
|
|
19
46
|
* ```ts
|
|
20
47
|
* const userType = type({
|
|
21
48
|
* displayName: nonEmptyStringWithMaxLength(64)
|
|
22
49
|
* });
|
|
23
50
|
* ```
|
|
51
|
+
*
|
|
52
|
+
* @__NO_SIDE_EFFECTS__
|
|
24
53
|
*/
|
|
25
54
|
export declare function nonEmptyStringWithMaxLength<N extends number>(maxLength: N): `string > 0 & string <= ${N}`;
|
|
@@ -5,9 +5,16 @@ import { type ReadKeyFunction } from '@dereekb/util';
|
|
|
5
5
|
* @param readKey - Function that extracts the key from each array element.
|
|
6
6
|
* @returns An ArkType schema that narrows `T[]` to ensure uniqueness.
|
|
7
7
|
*
|
|
8
|
+
* @dbxUtil
|
|
9
|
+
* @dbxUtilCategory validator
|
|
10
|
+
* @dbxUtilKind factory
|
|
11
|
+
* @dbxUtilTags validator, arktype, array, unique, uniqueness, keyed
|
|
12
|
+
*
|
|
8
13
|
* @example
|
|
9
14
|
* ```typescript
|
|
10
15
|
* const uniqueItemsType = uniqueKeyedType((item: Item) => item.id);
|
|
11
16
|
* ```
|
|
17
|
+
*
|
|
18
|
+
* @__NO_SIDE_EFFECTS__
|
|
12
19
|
*/
|
|
13
20
|
export declare function uniqueKeyedType<T>(readKey: ReadKeyFunction<T>): import("arktype/internal/variants/array.ts").ArrayType<unknown[], {}>;
|
|
@@ -1,8 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ArkType schema for a valid website URL (with or without protocol prefix).
|
|
3
|
+
*
|
|
4
|
+
* @dbxUtil
|
|
5
|
+
* @dbxUtilCategory validator
|
|
6
|
+
* @dbxUtilKind const
|
|
7
|
+
* @dbxUtilTags validator, arktype, url, website, string
|
|
8
|
+
* @dbxUtilRelated website-url-with-prefix-type
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* type({ website: websiteUrlType });
|
|
13
|
+
* ```
|
|
3
14
|
*/
|
|
4
15
|
export declare const websiteUrlType: import("arktype/internal/variants/string.ts").StringType<string, {}>;
|
|
5
16
|
/**
|
|
6
17
|
* ArkType schema for a valid website URL that starts with `http://` or `https://`.
|
|
18
|
+
*
|
|
19
|
+
* @dbxUtil
|
|
20
|
+
* @dbxUtilCategory validator
|
|
21
|
+
* @dbxUtilKind const
|
|
22
|
+
* @dbxUtilTags validator, arktype, url, website, prefix, https, string
|
|
23
|
+
* @dbxUtilRelated website-url-type
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* type({ website: websiteUrlWithPrefixType });
|
|
28
|
+
* ```
|
|
7
29
|
*/
|
|
8
30
|
export declare const websiteUrlWithPrefixType: import("arktype/internal/variants/string.ts").StringType<string, {}>;
|