@drawbridge/drawbridge-utils 0.0.102 → 0.0.103
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/dist/fields-validate.cjs +121 -0
- package/dist/fields-validate.d.cts +116 -0
- package/dist/fields-validate.d.ts +116 -0
- package/dist/fields-validate.js +94 -0
- package/package.json +9 -3
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// lib/fields-validate.js
|
|
20
|
+
var fields_validate_exports = {};
|
|
21
|
+
__export(fields_validate_exports, {
|
|
22
|
+
errors: () => errors,
|
|
23
|
+
validators: () => validators
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(fields_validate_exports);
|
|
26
|
+
|
|
27
|
+
// lib/phone.js
|
|
28
|
+
var import_libphonenumber_js = require("libphonenumber-js");
|
|
29
|
+
var isValid = (value, country) => {
|
|
30
|
+
if (!value) return false;
|
|
31
|
+
try {
|
|
32
|
+
return (0, import_libphonenumber_js.isValidPhoneNumber)(String(value), country);
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// lib/fields-validate.js
|
|
39
|
+
var errors = {
|
|
40
|
+
country: "Field is not an accepted value",
|
|
41
|
+
email: "Field value must be a valid email",
|
|
42
|
+
length: (length) => "Field must be less than or equal to " + length + " characters",
|
|
43
|
+
max: (val) => "Field value must be less than or equal to " + val,
|
|
44
|
+
min: (val) => "Field value must be greater than or equal to " + val,
|
|
45
|
+
option: "Field is not an accepted value",
|
|
46
|
+
phone: "Field value is not valid",
|
|
47
|
+
required: "Field is required"
|
|
48
|
+
};
|
|
49
|
+
var required = (field, schema) => {
|
|
50
|
+
var _a;
|
|
51
|
+
return ((_a = field == null ? void 0 : field.attributes) == null ? void 0 : _a.required) === false ? schema.nullable() : schema.required(errors.required);
|
|
52
|
+
};
|
|
53
|
+
var validators = {
|
|
54
|
+
// An agreement that is not required is not an agreement - consent stays
|
|
55
|
+
// affirmative regardless of the toggle.
|
|
56
|
+
agreement: (field, yup) => {
|
|
57
|
+
return yup.bool().required(errors.required).oneOf([true], errors.required);
|
|
58
|
+
},
|
|
59
|
+
email: (field, yup) => {
|
|
60
|
+
const max = 320;
|
|
61
|
+
return required(field, yup.string().email(errors.email).max(max, errors.length(max)));
|
|
62
|
+
},
|
|
63
|
+
name: (field, yup) => {
|
|
64
|
+
var _a;
|
|
65
|
+
const max = 150;
|
|
66
|
+
const object = (((_a = field == null ? void 0 : field.settings) == null ? void 0 : _a.capture) || []).reduce(
|
|
67
|
+
(accumulator, item) => {
|
|
68
|
+
accumulator[item] = yup.string().required(errors.required).max(max, errors.length(max));
|
|
69
|
+
return accumulator;
|
|
70
|
+
},
|
|
71
|
+
{}
|
|
72
|
+
);
|
|
73
|
+
return required(field, yup.object(object));
|
|
74
|
+
},
|
|
75
|
+
number: (field, yup) => {
|
|
76
|
+
var _a, _b, _c, _d, _e, _f;
|
|
77
|
+
let validate = yup.number();
|
|
78
|
+
if ((_a = field == null ? void 0 : field.attributes) == null ? void 0 : _a.min) {
|
|
79
|
+
validate = validate.min((_b = field == null ? void 0 : field.attributes) == null ? void 0 : _b.min, errors.min((_c = field == null ? void 0 : field.attributes) == null ? void 0 : _c.min));
|
|
80
|
+
}
|
|
81
|
+
;
|
|
82
|
+
if ((_d = field == null ? void 0 : field.attributes) == null ? void 0 : _d.max) {
|
|
83
|
+
validate = validate.max((_e = field == null ? void 0 : field.attributes) == null ? void 0 : _e.max, errors.max((_f = field == null ? void 0 : field.attributes) == null ? void 0 : _f.max));
|
|
84
|
+
}
|
|
85
|
+
;
|
|
86
|
+
return required(field, validate);
|
|
87
|
+
},
|
|
88
|
+
phone: (field, yup) => {
|
|
89
|
+
var _a;
|
|
90
|
+
return required(
|
|
91
|
+
field,
|
|
92
|
+
yup.object({
|
|
93
|
+
country: yup.string().required(errors.required).oneOf((_a = field == null ? void 0 : field.settings) == null ? void 0 : _a.countries, errors.country),
|
|
94
|
+
number: yup.string().required(errors.required)
|
|
95
|
+
}).test("phone", errors.phone, (value) => isValid(value == null ? void 0 : value.number, value == null ? void 0 : value.country))
|
|
96
|
+
);
|
|
97
|
+
},
|
|
98
|
+
// The in-list check the share form never had: the answer must be one of the
|
|
99
|
+
// field's own options. null rides the whitelist so an optional select can be
|
|
100
|
+
// left blank - required() still rejects null when the field is required.
|
|
101
|
+
select: (field, yup) => {
|
|
102
|
+
var _a;
|
|
103
|
+
const options = (((_a = field == null ? void 0 : field.settings) == null ? void 0 : _a.options) || []).map((item) => item == null ? void 0 : item.option);
|
|
104
|
+
return required(field, yup.string().oneOf([...options, null], errors.option));
|
|
105
|
+
},
|
|
106
|
+
text: (field, yup) => {
|
|
107
|
+
var _a;
|
|
108
|
+
const max = ((_a = field == null ? void 0 : field.attributes) == null ? void 0 : _a.max) || 150;
|
|
109
|
+
return required(field, yup.string().max(max, errors.length(max)));
|
|
110
|
+
},
|
|
111
|
+
textarea: (field, yup) => {
|
|
112
|
+
var _a;
|
|
113
|
+
const max = ((_a = field == null ? void 0 : field.attributes) == null ? void 0 : _a.max) || 150;
|
|
114
|
+
return required(field, yup.string().max(max, errors.length(max)));
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
118
|
+
0 && (module.exports = {
|
|
119
|
+
errors,
|
|
120
|
+
validators
|
|
121
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { isValid } from './phone.cjs';
|
|
2
|
+
import 'libphonenumber-js';
|
|
3
|
+
|
|
4
|
+
// Field validators shared by the share form (client) and the api submission
|
|
5
|
+
// route (server). They lived only in drawbridge-share, so every additional-field
|
|
6
|
+
// answer - number, select, text, textarea - was validated in the browser and
|
|
7
|
+
// stored as submitted; the api only ever validated lead fields.
|
|
8
|
+
//
|
|
9
|
+
// yup is passed in rather than imported so each consumer keeps its own copy
|
|
10
|
+
// (share bundles one, api has its own in lib/validate).
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
const errors = {
|
|
14
|
+
country : 'Field is not an accepted value',
|
|
15
|
+
email : 'Field value must be a valid email',
|
|
16
|
+
length : ( length ) => 'Field must be less than or equal to ' + length + ' characters',
|
|
17
|
+
max : ( val ) => 'Field value must be less than or equal to ' + val,
|
|
18
|
+
min : ( val ) => 'Field value must be greater than or equal to ' + val,
|
|
19
|
+
option : 'Field is not an accepted value',
|
|
20
|
+
phone : 'Field value is not valid',
|
|
21
|
+
required : 'Field is required'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Every stored attributes.required is currently true, so this is a no-op today -
|
|
25
|
+
// it is here so the optional-field toggle does not need a second pass over
|
|
26
|
+
// every builder.
|
|
27
|
+
const required = ( field, schema ) => ( field?.attributes?.required === false ) ? schema.nullable() : schema.required( errors.required );
|
|
28
|
+
|
|
29
|
+
const validators = {
|
|
30
|
+
// An agreement that is not required is not an agreement - consent stays
|
|
31
|
+
// affirmative regardless of the toggle.
|
|
32
|
+
agreement : ( field, yup ) => {
|
|
33
|
+
|
|
34
|
+
return yup.bool().required( errors.required ).oneOf( [ true ], errors.required );
|
|
35
|
+
|
|
36
|
+
},
|
|
37
|
+
email : ( field, yup ) => {
|
|
38
|
+
|
|
39
|
+
const max = 320;
|
|
40
|
+
|
|
41
|
+
return required( field, yup.string().email( errors.email ).max( max, errors.length( max ) ) );
|
|
42
|
+
|
|
43
|
+
},
|
|
44
|
+
name : ( field, yup ) => {
|
|
45
|
+
|
|
46
|
+
const max = 150;
|
|
47
|
+
|
|
48
|
+
const object = ( field?.settings?.capture || [] ).reduce(
|
|
49
|
+
( accumulator, item ) => {
|
|
50
|
+
|
|
51
|
+
accumulator[ item ] = yup.string().required( errors.required ).max( max, errors.length( max ) );
|
|
52
|
+
|
|
53
|
+
return accumulator;
|
|
54
|
+
|
|
55
|
+
},
|
|
56
|
+
{}
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return required( field, yup.object( object ) );
|
|
60
|
+
|
|
61
|
+
},
|
|
62
|
+
number : ( field, yup ) => {
|
|
63
|
+
|
|
64
|
+
let validate = yup.number();
|
|
65
|
+
|
|
66
|
+
if( field?.attributes?.min ){
|
|
67
|
+
|
|
68
|
+
validate = validate.min( field?.attributes?.min, errors.min( field?.attributes?.min ) );
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
if( field?.attributes?.max ){
|
|
72
|
+
|
|
73
|
+
validate = validate.max( field?.attributes?.max, errors.max( field?.attributes?.max ) );
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
return required( field, validate );
|
|
77
|
+
|
|
78
|
+
},
|
|
79
|
+
phone : ( field, yup ) => {
|
|
80
|
+
|
|
81
|
+
return required(
|
|
82
|
+
field,
|
|
83
|
+
yup.object({
|
|
84
|
+
country : yup.string().required( errors.required ).oneOf( field?.settings?.countries, errors.country ),
|
|
85
|
+
number : yup.string().required( errors.required )
|
|
86
|
+
}).test( 'phone', errors.phone, ( value ) => isValid( value?.number, value?.country ) )
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
},
|
|
90
|
+
// The in-list check the share form never had: the answer must be one of the
|
|
91
|
+
// field's own options. null rides the whitelist so an optional select can be
|
|
92
|
+
// left blank - required() still rejects null when the field is required.
|
|
93
|
+
select : ( field, yup ) => {
|
|
94
|
+
|
|
95
|
+
const options = ( field?.settings?.options || [] ).map( ( item ) => item?.option );
|
|
96
|
+
|
|
97
|
+
return required( field, yup.string().oneOf( [ ...options, null ], errors.option ) );
|
|
98
|
+
|
|
99
|
+
},
|
|
100
|
+
text : ( field, yup ) => {
|
|
101
|
+
|
|
102
|
+
const max = field?.attributes?.max || 150;
|
|
103
|
+
|
|
104
|
+
return required( field, yup.string().max( max, errors.length( max ) ) );
|
|
105
|
+
|
|
106
|
+
},
|
|
107
|
+
textarea : ( field, yup ) => {
|
|
108
|
+
|
|
109
|
+
const max = field?.attributes?.max || 150;
|
|
110
|
+
|
|
111
|
+
return required( field, yup.string().max( max, errors.length( max ) ) );
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export { errors, validators };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { isValid } from './phone.js';
|
|
2
|
+
import 'libphonenumber-js';
|
|
3
|
+
|
|
4
|
+
// Field validators shared by the share form (client) and the api submission
|
|
5
|
+
// route (server). They lived only in drawbridge-share, so every additional-field
|
|
6
|
+
// answer - number, select, text, textarea - was validated in the browser and
|
|
7
|
+
// stored as submitted; the api only ever validated lead fields.
|
|
8
|
+
//
|
|
9
|
+
// yup is passed in rather than imported so each consumer keeps its own copy
|
|
10
|
+
// (share bundles one, api has its own in lib/validate).
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
const errors = {
|
|
14
|
+
country : 'Field is not an accepted value',
|
|
15
|
+
email : 'Field value must be a valid email',
|
|
16
|
+
length : ( length ) => 'Field must be less than or equal to ' + length + ' characters',
|
|
17
|
+
max : ( val ) => 'Field value must be less than or equal to ' + val,
|
|
18
|
+
min : ( val ) => 'Field value must be greater than or equal to ' + val,
|
|
19
|
+
option : 'Field is not an accepted value',
|
|
20
|
+
phone : 'Field value is not valid',
|
|
21
|
+
required : 'Field is required'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Every stored attributes.required is currently true, so this is a no-op today -
|
|
25
|
+
// it is here so the optional-field toggle does not need a second pass over
|
|
26
|
+
// every builder.
|
|
27
|
+
const required = ( field, schema ) => ( field?.attributes?.required === false ) ? schema.nullable() : schema.required( errors.required );
|
|
28
|
+
|
|
29
|
+
const validators = {
|
|
30
|
+
// An agreement that is not required is not an agreement - consent stays
|
|
31
|
+
// affirmative regardless of the toggle.
|
|
32
|
+
agreement : ( field, yup ) => {
|
|
33
|
+
|
|
34
|
+
return yup.bool().required( errors.required ).oneOf( [ true ], errors.required );
|
|
35
|
+
|
|
36
|
+
},
|
|
37
|
+
email : ( field, yup ) => {
|
|
38
|
+
|
|
39
|
+
const max = 320;
|
|
40
|
+
|
|
41
|
+
return required( field, yup.string().email( errors.email ).max( max, errors.length( max ) ) );
|
|
42
|
+
|
|
43
|
+
},
|
|
44
|
+
name : ( field, yup ) => {
|
|
45
|
+
|
|
46
|
+
const max = 150;
|
|
47
|
+
|
|
48
|
+
const object = ( field?.settings?.capture || [] ).reduce(
|
|
49
|
+
( accumulator, item ) => {
|
|
50
|
+
|
|
51
|
+
accumulator[ item ] = yup.string().required( errors.required ).max( max, errors.length( max ) );
|
|
52
|
+
|
|
53
|
+
return accumulator;
|
|
54
|
+
|
|
55
|
+
},
|
|
56
|
+
{}
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return required( field, yup.object( object ) );
|
|
60
|
+
|
|
61
|
+
},
|
|
62
|
+
number : ( field, yup ) => {
|
|
63
|
+
|
|
64
|
+
let validate = yup.number();
|
|
65
|
+
|
|
66
|
+
if( field?.attributes?.min ){
|
|
67
|
+
|
|
68
|
+
validate = validate.min( field?.attributes?.min, errors.min( field?.attributes?.min ) );
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
if( field?.attributes?.max ){
|
|
72
|
+
|
|
73
|
+
validate = validate.max( field?.attributes?.max, errors.max( field?.attributes?.max ) );
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
return required( field, validate );
|
|
77
|
+
|
|
78
|
+
},
|
|
79
|
+
phone : ( field, yup ) => {
|
|
80
|
+
|
|
81
|
+
return required(
|
|
82
|
+
field,
|
|
83
|
+
yup.object({
|
|
84
|
+
country : yup.string().required( errors.required ).oneOf( field?.settings?.countries, errors.country ),
|
|
85
|
+
number : yup.string().required( errors.required )
|
|
86
|
+
}).test( 'phone', errors.phone, ( value ) => isValid( value?.number, value?.country ) )
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
},
|
|
90
|
+
// The in-list check the share form never had: the answer must be one of the
|
|
91
|
+
// field's own options. null rides the whitelist so an optional select can be
|
|
92
|
+
// left blank - required() still rejects null when the field is required.
|
|
93
|
+
select : ( field, yup ) => {
|
|
94
|
+
|
|
95
|
+
const options = ( field?.settings?.options || [] ).map( ( item ) => item?.option );
|
|
96
|
+
|
|
97
|
+
return required( field, yup.string().oneOf( [ ...options, null ], errors.option ) );
|
|
98
|
+
|
|
99
|
+
},
|
|
100
|
+
text : ( field, yup ) => {
|
|
101
|
+
|
|
102
|
+
const max = field?.attributes?.max || 150;
|
|
103
|
+
|
|
104
|
+
return required( field, yup.string().max( max, errors.length( max ) ) );
|
|
105
|
+
|
|
106
|
+
},
|
|
107
|
+
textarea : ( field, yup ) => {
|
|
108
|
+
|
|
109
|
+
const max = field?.attributes?.max || 150;
|
|
110
|
+
|
|
111
|
+
return required( field, yup.string().max( max, errors.length( max ) ) );
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export { errors, validators };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// lib/phone.js
|
|
2
|
+
import { parsePhoneNumberFromString, isValidPhoneNumber } from "libphonenumber-js";
|
|
3
|
+
var isValid = (value, country) => {
|
|
4
|
+
if (!value) return false;
|
|
5
|
+
try {
|
|
6
|
+
return isValidPhoneNumber(String(value), country);
|
|
7
|
+
} catch {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// lib/fields-validate.js
|
|
13
|
+
var errors = {
|
|
14
|
+
country: "Field is not an accepted value",
|
|
15
|
+
email: "Field value must be a valid email",
|
|
16
|
+
length: (length) => "Field must be less than or equal to " + length + " characters",
|
|
17
|
+
max: (val) => "Field value must be less than or equal to " + val,
|
|
18
|
+
min: (val) => "Field value must be greater than or equal to " + val,
|
|
19
|
+
option: "Field is not an accepted value",
|
|
20
|
+
phone: "Field value is not valid",
|
|
21
|
+
required: "Field is required"
|
|
22
|
+
};
|
|
23
|
+
var required = (field, schema) => {
|
|
24
|
+
var _a;
|
|
25
|
+
return ((_a = field == null ? void 0 : field.attributes) == null ? void 0 : _a.required) === false ? schema.nullable() : schema.required(errors.required);
|
|
26
|
+
};
|
|
27
|
+
var validators = {
|
|
28
|
+
// An agreement that is not required is not an agreement - consent stays
|
|
29
|
+
// affirmative regardless of the toggle.
|
|
30
|
+
agreement: (field, yup) => {
|
|
31
|
+
return yup.bool().required(errors.required).oneOf([true], errors.required);
|
|
32
|
+
},
|
|
33
|
+
email: (field, yup) => {
|
|
34
|
+
const max = 320;
|
|
35
|
+
return required(field, yup.string().email(errors.email).max(max, errors.length(max)));
|
|
36
|
+
},
|
|
37
|
+
name: (field, yup) => {
|
|
38
|
+
var _a;
|
|
39
|
+
const max = 150;
|
|
40
|
+
const object = (((_a = field == null ? void 0 : field.settings) == null ? void 0 : _a.capture) || []).reduce(
|
|
41
|
+
(accumulator, item) => {
|
|
42
|
+
accumulator[item] = yup.string().required(errors.required).max(max, errors.length(max));
|
|
43
|
+
return accumulator;
|
|
44
|
+
},
|
|
45
|
+
{}
|
|
46
|
+
);
|
|
47
|
+
return required(field, yup.object(object));
|
|
48
|
+
},
|
|
49
|
+
number: (field, yup) => {
|
|
50
|
+
var _a, _b, _c, _d, _e, _f;
|
|
51
|
+
let validate = yup.number();
|
|
52
|
+
if ((_a = field == null ? void 0 : field.attributes) == null ? void 0 : _a.min) {
|
|
53
|
+
validate = validate.min((_b = field == null ? void 0 : field.attributes) == null ? void 0 : _b.min, errors.min((_c = field == null ? void 0 : field.attributes) == null ? void 0 : _c.min));
|
|
54
|
+
}
|
|
55
|
+
;
|
|
56
|
+
if ((_d = field == null ? void 0 : field.attributes) == null ? void 0 : _d.max) {
|
|
57
|
+
validate = validate.max((_e = field == null ? void 0 : field.attributes) == null ? void 0 : _e.max, errors.max((_f = field == null ? void 0 : field.attributes) == null ? void 0 : _f.max));
|
|
58
|
+
}
|
|
59
|
+
;
|
|
60
|
+
return required(field, validate);
|
|
61
|
+
},
|
|
62
|
+
phone: (field, yup) => {
|
|
63
|
+
var _a;
|
|
64
|
+
return required(
|
|
65
|
+
field,
|
|
66
|
+
yup.object({
|
|
67
|
+
country: yup.string().required(errors.required).oneOf((_a = field == null ? void 0 : field.settings) == null ? void 0 : _a.countries, errors.country),
|
|
68
|
+
number: yup.string().required(errors.required)
|
|
69
|
+
}).test("phone", errors.phone, (value) => isValid(value == null ? void 0 : value.number, value == null ? void 0 : value.country))
|
|
70
|
+
);
|
|
71
|
+
},
|
|
72
|
+
// The in-list check the share form never had: the answer must be one of the
|
|
73
|
+
// field's own options. null rides the whitelist so an optional select can be
|
|
74
|
+
// left blank - required() still rejects null when the field is required.
|
|
75
|
+
select: (field, yup) => {
|
|
76
|
+
var _a;
|
|
77
|
+
const options = (((_a = field == null ? void 0 : field.settings) == null ? void 0 : _a.options) || []).map((item) => item == null ? void 0 : item.option);
|
|
78
|
+
return required(field, yup.string().oneOf([...options, null], errors.option));
|
|
79
|
+
},
|
|
80
|
+
text: (field, yup) => {
|
|
81
|
+
var _a;
|
|
82
|
+
const max = ((_a = field == null ? void 0 : field.attributes) == null ? void 0 : _a.max) || 150;
|
|
83
|
+
return required(field, yup.string().max(max, errors.length(max)));
|
|
84
|
+
},
|
|
85
|
+
textarea: (field, yup) => {
|
|
86
|
+
var _a;
|
|
87
|
+
const max = ((_a = field == null ? void 0 : field.attributes) == null ? void 0 : _a.max) || 150;
|
|
88
|
+
return required(field, yup.string().max(max, errors.length(max)));
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
export {
|
|
92
|
+
errors,
|
|
93
|
+
validators
|
|
94
|
+
};
|
package/package.json
CHANGED
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
"tinycolor2": "1.6.0"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@drawbridge/drawbridge-agents": "0.1.
|
|
16
|
+
"@drawbridge/drawbridge-agents": "0.1.37",
|
|
17
17
|
"@node-oauth/oauth2-server": "5.3.0",
|
|
18
18
|
"tsup": "8.5.1",
|
|
19
|
-
"typescript": "5.9.3"
|
|
19
|
+
"typescript": "5.9.3",
|
|
20
|
+
"yup": "1.7.1"
|
|
20
21
|
},
|
|
21
22
|
"peerDependencies": {
|
|
22
23
|
"@node-oauth/oauth2-server": "^5.3.0"
|
|
@@ -161,6 +162,11 @@
|
|
|
161
162
|
"types": "./dist/plans.d.ts",
|
|
162
163
|
"import": "./dist/plans.js",
|
|
163
164
|
"require": "./dist/plans.cjs"
|
|
165
|
+
},
|
|
166
|
+
"./fields-validate": {
|
|
167
|
+
"types": "./dist/fields-validate.d.ts",
|
|
168
|
+
"import": "./dist/fields-validate.js",
|
|
169
|
+
"require": "./dist/fields-validate.cjs"
|
|
164
170
|
}
|
|
165
171
|
},
|
|
166
172
|
"files": [
|
|
@@ -179,5 +185,5 @@
|
|
|
179
185
|
"test": ". \"$HOME/.nvm/nvm.sh\" && nvm use && node --test"
|
|
180
186
|
},
|
|
181
187
|
"types": "dist/index.d.ts",
|
|
182
|
-
"version": "0.0.
|
|
188
|
+
"version": "0.0.103"
|
|
183
189
|
}
|