remult 0.25.1 → 0.25.2

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,5 +1,5 @@
1
1
  export {};
2
- //y1 - discuss limit and include queries
2
+ //y1 - number default storage in knex is decimal and it by default has 8,2 - meaning only 999,999 - I think it should be way bigger than that. in firefly we do at least 18 - https://discord.com/channels/975754286384418847/1195162533447876658
3
3
  //y1 - tried to upgrade vitest, nuxt tests are failing with loading uuid - sounds familiar?
4
4
  //y2 - from the crm-demo(https://crm-demo.up.railway.app/deals), after editing a deal: - _updateEntityBasedOnApi
5
5
  //y2 - Backend methods are transactions, it's not intuitive and maybe should be optional / opt in
@@ -71,3 +71,4 @@ remult.apiClient.url='localhost:3007/api
71
71
  //y2 - consider if field types should include validation in them by default (string,number that it's not NaN etc...) and if so, what message?
72
72
  //y2 - should enforce integer - currently we probably round / truncate it
73
73
  //p1 - adjust react tutorial to esm
74
+ //p1 - write docs on with remult - and usage in init api
@@ -39,6 +39,7 @@ export class Validators {
39
39
  return Boolean(await e.load());
40
40
  }, 'Relation value does not exist');
41
41
  static maxLength = createValueValidatorWithArgs((val, maxLength) => val.length <= maxLength, (maxLength) => `Value must be at most ${maxLength} characters`);
42
+ static minLength = createValueValidatorWithArgs((val, minLength) => val.length >= minLength, (maxLength) => `Value must be at least ${maxLength} characters`);
42
43
  static defaultMessage = 'Invalid value';
43
44
  }
44
45
  export function createValidator(validate, defaultMessage) {
@@ -63,16 +64,18 @@ export function createValidator(validate, defaultMessage) {
63
64
  }
64
65
  return validation(entityOrMessage, e, message);
65
66
  };
66
- //@ts-ignore
67
- return Object.assign(result, {
68
- withMessage: (message) => async (entity, e) => result(entity, e, message),
69
- get defaultMessage() {
67
+ Object.defineProperty(result, 'defaultMessage', {
68
+ get: () => {
70
69
  return defaultMessage;
71
70
  },
72
- set defaultMessage(val) {
71
+ set: (val) => {
73
72
  defaultMessage = val;
74
73
  },
75
- isValid: validate,
74
+ enumerable: true,
75
+ });
76
+ //@ts-ignore
77
+ return Object.assign(result, {
78
+ withMessage: (message) => async (entity, e) => result(entity, e, message),
76
79
  });
77
80
  }
78
81
  export function valueValidator(validate, defaultMessage) {
@@ -123,6 +126,3 @@ export function createValidatorWithArgs(validate, defaultMessage) {
123
126
  },
124
127
  });
125
128
  }
126
- //y1 - talk about the 3rd parameter as message
127
- //y1 - talk about the changed signature breaking existing validations and preventing the usage of unique outside the normal flow
128
- //y1 - talk about the defaultMessage value now being a function that get's too many arguments, that makes it's reuse that much harder
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "0.25.1",
3
+ "version": "0.25.2",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "homepage": "https://remult.dev",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //y1 - discuss limit and include queries
3
+ //y1 - number default storage in knex is decimal and it by default has 8,2 - meaning only 999,999 - I think it should be way bigger than that. in firefly we do at least 18 - https://discord.com/channels/975754286384418847/1195162533447876658
4
4
  //y1 - tried to upgrade vitest, nuxt tests are failing with loading uuid - sounds familiar?
5
5
  //y2 - from the crm-demo(https://crm-demo.up.railway.app/deals), after editing a deal: - _updateEntityBasedOnApi
6
6
  //y2 - Backend methods are transactions, it's not intuitive and maybe should be optional / opt in
@@ -72,3 +72,4 @@ remult.apiClient.url='localhost:3007/api
72
72
  //y2 - consider if field types should include validation in them by default (string,number that it's not NaN etc...) and if so, what message?
73
73
  //y2 - should enforce integer - currently we probably round / truncate it
74
74
  //p1 - adjust react tutorial to esm
75
+ //p1 - write docs on with remult - and usage in init api
@@ -23,6 +23,9 @@ export declare class Validators {
23
23
  static maxLength: ValidatorWithArgs<string, number> & {
24
24
  defaultMessage: ValueValidationMessage<number>;
25
25
  };
26
+ static minLength: ValidatorWithArgs<string, number> & {
27
+ defaultMessage: ValueValidationMessage<number>;
28
+ };
26
29
  static defaultMessage: string;
27
30
  }
28
31
  export type Validator<valueType> = FieldValidator<any, valueType> & ((message?: ValidationMessage<valueType, undefined>) => FieldValidator<any, valueType>) & {
package/src/validators.js CHANGED
@@ -71,6 +71,7 @@ var Validators = /** @class */ (function () {
71
71
  });
72
72
  }); }, 'Relation value does not exist');
73
73
  Validators.maxLength = createValueValidatorWithArgs(function (val, maxLength) { return val.length <= maxLength; }, function (maxLength) { return "Value must be at most ".concat(maxLength, " characters"); });
74
+ Validators.minLength = createValueValidatorWithArgs(function (val, minLength) { return val.length >= minLength; }, function (maxLength) { return "Value must be at least ".concat(maxLength, " characters"); });
74
75
  Validators.defaultMessage = 'Invalid value';
75
76
  return Validators;
76
77
  }());
@@ -111,6 +112,15 @@ function createValidator(validate, defaultMessage) {
111
112
  }
112
113
  return validation(entityOrMessage, e, message);
113
114
  };
115
+ Object.defineProperty(result, 'defaultMessage', {
116
+ get: function () {
117
+ return defaultMessage;
118
+ },
119
+ set: function (val) {
120
+ defaultMessage = val;
121
+ },
122
+ enumerable: true,
123
+ });
114
124
  //@ts-ignore
115
125
  return Object.assign(result, {
116
126
  withMessage: function (message) {
@@ -118,13 +128,6 @@ function createValidator(validate, defaultMessage) {
118
128
  return [2 /*return*/, result(entity, e, message)];
119
129
  }); }); };
120
130
  },
121
- get defaultMessage() {
122
- return defaultMessage;
123
- },
124
- set defaultMessage(val) {
125
- defaultMessage = val;
126
- },
127
- isValid: validate,
128
131
  });
129
132
  }
130
133
  exports.createValidator = createValidator;
@@ -195,6 +198,3 @@ function createValidatorWithArgs(validate, defaultMessage) {
195
198
  });
196
199
  }
197
200
  exports.createValidatorWithArgs = createValidatorWithArgs;
198
- //y1 - talk about the 3rd parameter as message
199
- //y1 - talk about the changed signature breaking existing validations and preventing the usage of unique outside the normal flow
200
- //y1 - talk about the defaultMessage value now being a function that get's too many arguments, that makes it's reuse that much harder