@joeygrable94/utm-src-pub-validators 0.0.4 → 0.0.5

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.
@@ -1,90 +0,0 @@
1
- import * as v from 'valibot'
2
- import {
3
- LIMIT_MAX_LABEL,
4
- LIMIT_MIN_LABEL,
5
- LIMIT_MAX_VALUE,
6
- LIMIT_MIN_VALUE,
7
- LIMIT_MAX_DESCRIPTION,
8
- LIMIT_MIN_NAME,
9
- LIMIT_MAX_NAME
10
- } from './constants-limits'
11
- import { ERROR_MESSAGE_REGEX_VALUE, REGEX_VALUE } from './constants-regex'
12
-
13
- // reference id for relationships
14
- export const IsValidReferenceId = v.object({
15
- id: v.number('please provide a valid id number')
16
- })
17
-
18
- // cost
19
- export const IsValidCost = v.pipe(
20
- v.number('please enter a cost value'),
21
- v.minValue(0),
22
- v.maxValue(
23
- 1000000,
24
- 'your campaign cost exceeds our $1 million dollar limit, please contact us for enterprise solutions'
25
- )
26
- )
27
- export const IsValidOrUndefinedCost = v.undefinedable(IsValidCost)
28
-
29
- // label
30
- export const IsValidLabel = v.pipe(
31
- v.string('please provide a label'),
32
- v.trim(),
33
- v.minLength(
34
- LIMIT_MIN_LABEL,
35
- `the label is too short, it must be at least ${LIMIT_MIN_LABEL} characters`
36
- ),
37
- v.maxLength(
38
- LIMIT_MAX_LABEL,
39
- `the label is too long, it must be ${LIMIT_MAX_LABEL} characters or less`
40
- )
41
- )
42
- export const IsValidOrUndefinedLabel = v.undefinedable(IsValidLabel)
43
-
44
- // value
45
- export const IsValidValue = v.pipe(
46
- v.string('please provide a value'),
47
- v.trim(),
48
- v.minLength(
49
- LIMIT_MIN_VALUE,
50
- `the value is too short, it must be at least ${LIMIT_MIN_VALUE} characters`
51
- ),
52
- v.maxLength(
53
- LIMIT_MAX_VALUE,
54
- `the value is too long, it must be ${LIMIT_MAX_VALUE} characters or less`
55
- ),
56
- v.regex(REGEX_VALUE, `the value ${ERROR_MESSAGE_REGEX_VALUE}`)
57
- )
58
- export const IsValidOrUndefinedValue = v.undefinedable(IsValidValue)
59
-
60
- // description (optional)
61
- export const IsValidDescription = v.nullable(
62
- v.pipe(
63
- v.string('the description must be a string'),
64
- v.trim(),
65
- v.maxLength(
66
- LIMIT_MAX_DESCRIPTION,
67
- `the description is too long, it must be ${LIMIT_MAX_DESCRIPTION} characters or less`
68
- )
69
- )
70
- )
71
- export const IsValidOrUndefinedDescription = v.optional(IsValidDescription)
72
-
73
- // is_active
74
- export const IsValidIsActive = v.boolean('isActive must be a boolean')
75
- export const IsValidOrUndefinedIsActive = v.undefinedable(IsValidIsActive)
76
-
77
- // name
78
- export const IsValidName = v.pipe(
79
- v.string('please provide a name'),
80
- v.trim(),
81
- v.minLength(
82
- LIMIT_MIN_NAME,
83
- `the name is too short, it must be at least ${LIMIT_MIN_NAME} characters`
84
- ),
85
- v.maxLength(
86
- LIMIT_MAX_NAME,
87
- `the name is too long, it must be ${LIMIT_MAX_NAME} characters or less`
88
- )
89
- )
90
- export const IsValidOrUndefinedName = v.undefinedable(IsValidName)
@@ -1,15 +0,0 @@
1
- import * as v from 'valibot'
2
-
3
- export const IsValidApplyValueTo = v.picklist([
4
- 'source',
5
- 'medium',
6
- 'campaign',
7
- 'content',
8
- 'creative',
9
- 'term',
10
- 'id'
11
- ])
12
- export const IsValidOrUndefinedApplyValueTo = v.nullable(IsValidApplyValueTo)
13
-
14
- export const IsValidApplyValueAs = v.picklist(['prefix', 'suffix'])
15
- export const IsValidOrUndefinedApplyValueAs = v.nullable(IsValidApplyValueAs)
@@ -1,65 +0,0 @@
1
- import * as v from 'valibot'
2
- import {
3
- LIMIT_MIN_PRICE_ID,
4
- LIMIT_MAX_PRICE_ID,
5
- LIMIT_MIN_UNIT_AMOUNT,
6
- LIMIT_MIN_UNIT_TERM_IN_MONTHS,
7
- LIMIT_MAX_UNIT_TERM_IN_MONTHS,
8
- LIMIT_MIN_PRODUCT_ID,
9
- LIMIT_MAX_PRODUCT_ID
10
- } from './constants-limits'
11
-
12
- // product_id
13
- export const IsValidProductId = v.pipe(
14
- v.string('please provide a product_id'),
15
- v.trim(),
16
- v.minLength(
17
- LIMIT_MIN_PRODUCT_ID,
18
- `the product_id is too short, it must be at least ${LIMIT_MIN_PRODUCT_ID} characters`
19
- ),
20
- v.maxLength(
21
- LIMIT_MAX_PRODUCT_ID,
22
- `the product_id is too long, it must be ${LIMIT_MAX_PRODUCT_ID} characters or less`
23
- )
24
- )
25
- export const IsValidOrUndefinedProductId = v.undefinedable(IsValidProductId)
26
-
27
- // price_id
28
- export const IsValidPriceId = v.pipe(
29
- v.string('please provide a price_id'),
30
- v.trim(),
31
- v.minLength(
32
- LIMIT_MIN_PRICE_ID,
33
- `the price_id is too short, it must be at least ${LIMIT_MIN_PRICE_ID} characters`
34
- ),
35
- v.maxLength(
36
- LIMIT_MAX_PRICE_ID,
37
- `the price_id is too long, it must be ${LIMIT_MAX_PRICE_ID} characters or less`
38
- )
39
- )
40
- export const IsValidOrUndefinedPriceId = v.undefinedable(IsValidPriceId)
41
-
42
- // unit_amount
43
- export const IsValidUnitAmount = v.pipe(
44
- v.number('please provide a unit_amount'),
45
- v.minValue(
46
- LIMIT_MIN_UNIT_AMOUNT,
47
- `the unit_amount must be a decimal greater than or equal to ${LIMIT_MIN_UNIT_AMOUNT}`
48
- )
49
- )
50
- export const IsValidOrUndefinedUnitAmount = v.undefinedable(IsValidUnitAmount)
51
-
52
- export const IsValidUnitTermInMonths = v.pipe(
53
- v.number('please provide a unit_term_in_months'),
54
- v.minValue(
55
- LIMIT_MIN_UNIT_TERM_IN_MONTHS,
56
- `the unit_term_in_months must be an integer greater than or equal to ${LIMIT_MIN_UNIT_TERM_IN_MONTHS}`
57
- ),
58
- v.maxValue(
59
- LIMIT_MAX_UNIT_TERM_IN_MONTHS,
60
- `the unit_term_in_months must be an integer less than or equal to ${LIMIT_MAX_UNIT_TERM_IN_MONTHS}`
61
- )
62
- )
63
- export const IsValidOrUndefinedUnitTermInMonths = v.undefinedable(
64
- IsValidUnitTermInMonths
65
- )
@@ -1,98 +0,0 @@
1
- import * as v from 'valibot'
2
- import {
3
- LIMIT_MAX_DESTINATION,
4
- LIMIT_MAX_DOMAIN,
5
- LIMIT_MAX_FRAGMENT,
6
- LIMIT_MAX_PATH,
7
- LIMIT_MAX_QUERY,
8
- LIMIT_MIN_DESTINATION,
9
- LIMIT_MIN_DOMAIN,
10
- LIMIT_MIN_FRAGMENT,
11
- LIMIT_MIN_PATH,
12
- LIMIT_MIN_QUERY
13
- } from './constants-limits'
14
- import { ERROR_MESSAGE_REGEX_DOMAIN, REGEX_DOMAIN } from './constants-regex'
15
-
16
- // destination
17
- export const IsValidUrlDestination = v.pipe(
18
- v.string('please provide a url destination'),
19
- v.trim(),
20
- v.minLength(
21
- LIMIT_MIN_DESTINATION,
22
- `the url destination is too short, it must be at least ${LIMIT_MIN_DESTINATION} characters`
23
- ),
24
- v.maxLength(
25
- LIMIT_MAX_DESTINATION,
26
- `the url destination is too long, it must be ${LIMIT_MAX_DESTINATION} characters or less`
27
- ),
28
- v.url('please provide a valid url')
29
- )
30
- export const IsValidOrUndefinedUrlDestination = v.nullable(IsValidUrlDestination)
31
-
32
- // protocol
33
- export const IsValidUrlProtocol = v.picklist(
34
- ['http', 'https'],
35
- 'please provide a valid url protocol'
36
- )
37
- export const IsValidOrUndefinedUrlProtocol = v.nullable(IsValidUrlProtocol)
38
-
39
- // domain
40
- export const IsValidUrlDomain = v.pipe(
41
- v.string('please provide a domain'),
42
- v.trim(),
43
- v.minLength(
44
- LIMIT_MIN_DOMAIN,
45
- `the domain is too short, it must be at least ${LIMIT_MIN_DOMAIN} characters`
46
- ),
47
- v.maxLength(
48
- LIMIT_MAX_DOMAIN,
49
- `the domain is too long, it must be ${LIMIT_MAX_DOMAIN} characters or less`
50
- ),
51
- v.regex(REGEX_DOMAIN, ERROR_MESSAGE_REGEX_DOMAIN)
52
- )
53
- export const IsValidOrUndefinedUrlDomain = v.nullable(IsValidUrlDomain)
54
-
55
- // path
56
- export const IsValidUrlPath = v.pipe(
57
- v.string('please provide a url path'),
58
- v.trim(),
59
- v.minLength(
60
- LIMIT_MIN_PATH,
61
- `the url path is too short, it must be at least ${LIMIT_MIN_PATH} characters`
62
- ),
63
- v.maxLength(
64
- LIMIT_MAX_PATH,
65
- `the url path is too long, it must be ${LIMIT_MAX_PATH} characters or less`
66
- )
67
- )
68
- export const IsValidOrUndefinedUrlPath = v.nullable(IsValidUrlPath)
69
-
70
- // query
71
- export const IsValidUrlQuery = v.pipe(
72
- v.string('please provide a url query'),
73
- v.trim(),
74
- v.minLength(
75
- LIMIT_MIN_QUERY,
76
- `the url query is too short, it must be at least ${LIMIT_MIN_QUERY} characters`
77
- ),
78
- v.maxLength(
79
- LIMIT_MAX_QUERY,
80
- `the url query is too long, it must be ${LIMIT_MAX_QUERY} characters or less`
81
- )
82
- )
83
- export const IsValidOrUndefinedUrlQuery = v.nullable(IsValidUrlQuery)
84
-
85
- // fragment
86
- export const IsValidUrlFragment = v.pipe(
87
- v.string('please provide a url hash/fragment'),
88
- v.trim(),
89
- v.minLength(
90
- LIMIT_MIN_FRAGMENT,
91
- `the url hash/fragment is too short, it must be at least ${LIMIT_MIN_FRAGMENT} characters`
92
- ),
93
- v.maxLength(
94
- LIMIT_MAX_FRAGMENT,
95
- `the url hash/fragment is too long, it must be ${LIMIT_MAX_FRAGMENT} characters or less`
96
- )
97
- )
98
- export const IsValidOrUndefinedUrlFragment = v.nullable(IsValidUrlFragment)
@@ -1,71 +0,0 @@
1
- import * as v from 'valibot'
2
- import {
3
- LIMIT_MAX_EMAIL,
4
- LIMIT_MAX_PASSWORD,
5
- LIMIT_MAX_PROVIDER,
6
- LIMIT_MAX_USERNAME,
7
- LIMIT_MIN_EMAIL,
8
- LIMIT_MIN_PASSWORD,
9
- LIMIT_MIN_USERNAME
10
- } from './constants-limits'
11
- import { ERROR_MESSAGE_REGEX_VALUE, REGEX_VALUE } from './constants-regex'
12
-
13
- export const IsValidUsername = v.pipe(
14
- v.string('please provide a username'),
15
- v.trim(),
16
- v.minLength(
17
- LIMIT_MIN_USERNAME,
18
- `your username is too short, it must be at least ${LIMIT_MIN_USERNAME} characters`
19
- ),
20
- v.maxLength(
21
- LIMIT_MAX_USERNAME,
22
- `your username is too long, it must be ${LIMIT_MAX_USERNAME} characters or less`
23
- ),
24
- v.regex(REGEX_VALUE, `your username ${ERROR_MESSAGE_REGEX_VALUE}`)
25
- )
26
- export const IsValidOrUndefinedUsername = v.undefinedable(IsValidUsername)
27
-
28
- export const IsValidEmail = v.pipe(
29
- v.string('please provide an email'),
30
- v.trim(),
31
- v.minLength(
32
- LIMIT_MIN_EMAIL,
33
- `your email is too short, it must be at least ${LIMIT_MIN_EMAIL} characters`
34
- ),
35
- v.maxLength(
36
- LIMIT_MAX_EMAIL,
37
- `your email is too long, it must be ${LIMIT_MAX_EMAIL} characters or less`
38
- ),
39
- v.email('please provide a valid email address')
40
- )
41
- export const IsValidOrUndefinedEmail = v.undefinedable(IsValidEmail)
42
-
43
- export const IsValidPassword = v.pipe(
44
- v.string('a password is required'),
45
- v.trim(),
46
- v.minLength(
47
- LIMIT_MIN_PASSWORD,
48
- `your password is too short, it must be at least ${LIMIT_MIN_PASSWORD} characters`
49
- ),
50
- v.maxLength(
51
- LIMIT_MAX_PASSWORD,
52
- `your password is too long, it must be ${LIMIT_MAX_PASSWORD} characters or less`
53
- )
54
- )
55
- export const IsValidOrUndefinedPassword = v.undefinedable(IsValidPassword)
56
-
57
- export const IsValidProvider = v.pipe(
58
- v.string('please enter a provider'),
59
- v.trim(),
60
- v.maxLength(
61
- LIMIT_MAX_PROVIDER,
62
- `the provider string is too long, it must be ${LIMIT_MAX_PROVIDER} characters or less`
63
- )
64
- )
65
- export const IsValidOrUndefinedProvider = v.undefinedable(IsValidProvider)
66
-
67
- export const IsValidConfirmed = v.boolean()
68
- export const IsValidOrUndefinedConfirmed = v.undefinedable(IsValidConfirmed)
69
-
70
- export const IsValidBlocked = v.boolean()
71
- export const IsValidOrUndefinedBlocked = v.undefinedable(IsValidBlocked)
@@ -1,132 +0,0 @@
1
- import * as v from 'valibot'
2
- import {
3
- LIMIT_MAX_UTM_CAMPAIGN,
4
- LIMIT_MAX_UTM_CREATIVE_FORMAT,
5
- LIMIT_MAX_UTM_MEDIUM,
6
- LIMIT_MAX_UTM_SOURCE,
7
- LIMIT_MIN_UTM_CAMPAIGN,
8
- LIMIT_MIN_UTM_CREATIVE_FORMAT,
9
- LIMIT_MIN_UTM_MEDIUM,
10
- LIMIT_MIN_UTM_SOURCE,
11
- LIMIT_MIN_UTM_CONTENT,
12
- LIMIT_MAX_UTM_CONTENT,
13
- LIMIT_MIN_UTM_TERM,
14
- LIMIT_MAX_UTM_TERM,
15
- LIMIT_MIN_UTM_ID,
16
- LIMIT_MAX_UTM_ID
17
- } from './constants-limits'
18
- import { ERROR_MESSAGE_REGEX_VALUE, REGEX_VALUE } from './constants-regex'
19
-
20
- // utm_source
21
- export const IsValidUrlUtmSource = v.pipe(
22
- v.string(),
23
- v.trim(),
24
- v.minLength(
25
- LIMIT_MIN_UTM_SOURCE,
26
- `the utm_source is too short, it must be at least ${LIMIT_MIN_UTM_SOURCE} characters`
27
- ),
28
- v.maxLength(
29
- LIMIT_MAX_UTM_SOURCE,
30
- `the utm_source is too long, it must be ${LIMIT_MAX_UTM_SOURCE} characters or less`
31
- ),
32
- v.regex(REGEX_VALUE, `utm_source ${ERROR_MESSAGE_REGEX_VALUE}`)
33
- )
34
- export const IsValidOrUndefinedUrlUtmSource = v.nullable(IsValidUrlUtmSource)
35
-
36
- // utm_medium
37
- export const IsValidUrlUtmMedium = v.pipe(
38
- v.string(),
39
- v.trim(),
40
- v.minLength(
41
- LIMIT_MIN_UTM_MEDIUM,
42
- `the utm_medium is too short, it must be at least ${LIMIT_MIN_UTM_MEDIUM} characters`
43
- ),
44
- v.maxLength(
45
- LIMIT_MAX_UTM_MEDIUM,
46
- `the utm_medium is too long, it must be ${LIMIT_MAX_UTM_MEDIUM} characters or less`
47
- ),
48
- v.regex(REGEX_VALUE, `utm_medium ${ERROR_MESSAGE_REGEX_VALUE}`)
49
- )
50
- export const IsValidOrUndefinedUrlUtmMedium = v.nullable(IsValidUrlUtmMedium)
51
-
52
- // utm_campaign
53
- export const IsValidUrlUtmCampaign = v.pipe(
54
- v.string(),
55
- v.trim(),
56
- v.minLength(
57
- LIMIT_MIN_UTM_CAMPAIGN,
58
- `the utm_campaign is too short, it must be at least ${LIMIT_MIN_UTM_CAMPAIGN} characters`
59
- ),
60
- v.maxLength(
61
- LIMIT_MAX_UTM_CAMPAIGN,
62
- `the utm_campaign is too long, it must be ${LIMIT_MAX_UTM_CAMPAIGN} characters or less`
63
- ),
64
- v.regex(REGEX_VALUE, `utm_campaign ${ERROR_MESSAGE_REGEX_VALUE}`)
65
- )
66
- export const IsValidOrUndefinedUrlUtmCampaign = v.nullable(IsValidUrlUtmCampaign)
67
-
68
- // utm_creative_format
69
- export const IsValidUrlUtmCreativeFormat = v.pipe(
70
- v.string(),
71
- v.trim(),
72
- v.minLength(
73
- LIMIT_MIN_UTM_CREATIVE_FORMAT,
74
- `the utm_creative_format is too short, it must be at least ${LIMIT_MIN_UTM_CREATIVE_FORMAT} characters`
75
- ),
76
- v.maxLength(
77
- LIMIT_MAX_UTM_CREATIVE_FORMAT,
78
- `the utm_creative_format is too long, it must be ${LIMIT_MAX_UTM_CREATIVE_FORMAT} characters or less`
79
- ),
80
- v.regex(REGEX_VALUE, `utm_creative_format ${ERROR_MESSAGE_REGEX_VALUE}`)
81
- )
82
- export const IsValidOrUndefinedUrlUtmCreativeFormat = v.nullable(
83
- IsValidUrlUtmCreativeFormat
84
- )
85
-
86
- // utm_content
87
- export const IsValidUrlUtmContent = v.pipe(
88
- v.string(),
89
- v.trim(),
90
- v.minLength(
91
- LIMIT_MIN_UTM_CONTENT,
92
- `the utm_content is too short, it must be at least ${LIMIT_MIN_UTM_CONTENT} characters`
93
- ),
94
- v.maxLength(
95
- LIMIT_MAX_UTM_CONTENT,
96
- `the utm_content is too long, it must be ${LIMIT_MAX_UTM_CONTENT} characters or less`
97
- ),
98
- v.regex(REGEX_VALUE, `utm_content ${ERROR_MESSAGE_REGEX_VALUE}`)
99
- )
100
- export const IsValidOrUndefinedUrlUtmContent = v.nullable(IsValidUrlUtmContent)
101
-
102
- // utm_term
103
- export const IsValidUrlUtmTerm = v.pipe(
104
- v.string(),
105
- v.trim(),
106
- v.minLength(
107
- LIMIT_MIN_UTM_TERM,
108
- `the utm_term is too short, it must be at least ${LIMIT_MIN_UTM_TERM} characters`
109
- ),
110
- v.maxLength(
111
- LIMIT_MAX_UTM_TERM,
112
- `the utm_term is too long, it must be ${LIMIT_MAX_UTM_TERM} characters or less`
113
- ),
114
- v.regex(REGEX_VALUE, `utm_term ${ERROR_MESSAGE_REGEX_VALUE}`)
115
- )
116
- export const IsValidOrUndefinedUrlUtmTerm = v.nullable(IsValidUrlUtmTerm)
117
-
118
- // utm_id
119
- export const IsValidUrlUtmId = v.pipe(
120
- v.string(),
121
- v.trim(),
122
- v.minLength(
123
- LIMIT_MIN_UTM_ID,
124
- `the utm_id is too short, it must be at least ${LIMIT_MIN_UTM_ID} characters`
125
- ),
126
- v.maxLength(
127
- LIMIT_MAX_UTM_ID,
128
- `the utm_id is too long, it must be ${LIMIT_MAX_UTM_ID} characters or less`
129
- ),
130
- v.regex(REGEX_VALUE, `utm_id ${ERROR_MESSAGE_REGEX_VALUE}`)
131
- )
132
- export const IsValidOrUndefinedUrlUtmId = v.nullable(IsValidUrlUtmId)