nicot 1.4.3 → 1.4.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/dist/index.cjs CHANGED
@@ -1181,12 +1181,30 @@ var BoolColumn = (options = {}) => (0, import_nesties4.MergePropertyDecorators)(
1181
1181
  swaggerDecorator(options, { type: Boolean }),
1182
1182
  GetMutatorBool()
1183
1183
  ]);
1184
+ var jsonColumnValidators = (definition) => {
1185
+ const isArray = Array.isArray(definition);
1186
+ const cl = (0, import_nesties5.getClassFromClassOrArray)(definition);
1187
+ const validationOptions = isArray ? { each: true } : {};
1188
+ const decorators = isArray ? [(0, import_class_validator3.IsArray)()] : [];
1189
+ if (cl === String) {
1190
+ decorators.push((0, import_class_validator3.IsString)(validationOptions));
1191
+ } else if (cl === Number) {
1192
+ decorators.push((0, import_class_validator3.IsNumber)({}, validationOptions));
1193
+ } else if (cl === Boolean) {
1194
+ decorators.push((0, import_class_validator3.IsBoolean)(validationOptions));
1195
+ } else if (cl === Date) {
1196
+ decorators.push((0, import_class_validator3.IsDate)(validationOptions));
1197
+ } else {
1198
+ decorators.push((0, import_class_validator3.ValidateNested)(validationOptions));
1199
+ }
1200
+ return decorators;
1201
+ };
1184
1202
  var createJsonColumnDef = (columnType = "jsonb", typeTransformerClass = TypeTransformer) => (definition, options = {}) => {
1185
1203
  const cl = (0, import_nesties5.getClassFromClassOrArray)(definition);
1186
1204
  return (0, import_nesties4.MergePropertyDecorators)([
1187
1205
  RequireGetMutator(),
1188
1206
  (0, import_class_transformer2.Type)(() => cl),
1189
- (0, import_class_validator3.ValidateNested)(),
1207
+ ...jsonColumnValidators(definition),
1190
1208
  (0, import_typeorm.Column)(options.columnType || columnType, {
1191
1209
  ...columnDecoratorOptions(options),
1192
1210
  transformer: new typeTransformerClass(definition)