valgen 5.19.4 → 5.19.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.
package/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = '5.19.4';
1
+ export const version = '5.19.5';
2
2
  export const postValidation = Symbol('postValidation');
3
3
  export const preValidation = Symbol('preValidation');
4
4
  export const VALIDATE_METADATA = Symbol('VALIDATE_METADATA');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "valgen",
3
3
  "description": "Fast runtime type validator, converter and io (encoding/decoding) library",
4
- "version": "5.19.4",
4
+ "version": "5.19.5",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {
@@ -50,7 +50,7 @@ export function isDateString(options) {
50
50
  if (parsed.precision < precisionMinIdx) {
51
51
  context.fail(_this, `Minimum date precision should be ${precisionMin}`, input, options);
52
52
  }
53
- if (parsed.precision > precisionMaxIdx) {
53
+ if (parsed.precision > precisionMaxIdx && !(input instanceof Date)) {
54
54
  context.fail(_this, `Maximum date precision should be ${precisionMax}`, input, options);
55
55
  }
56
56
  return coerce ? parsed.value : input;
@@ -75,8 +75,11 @@ function coerceDateString(input, trimPrecision) {
75
75
  String(d.getMinutes()).padStart(2, '0'),
76
76
  String(d.getSeconds()).padStart(2, '0'),
77
77
  ];
78
- if (precisionIndex >= 7 && d.getMilliseconds() > 0)
79
- dateParts.push(String(d.getMilliseconds()).padStart(3, '0'));
78
+ if (precisionIndex >= 7)
79
+ if (d.getMilliseconds() > 0)
80
+ dateParts.push(String(d.getMilliseconds()).padStart(3, '0'));
81
+ else
82
+ dateParts.push('');
80
83
  if (precisionIndex >= 8) {
81
84
  const tzOffset = d.getTimezoneOffset();
82
85
  const tz = tzOffset > 0
@@ -13,7 +13,6 @@ export function isEnum(values, options) {
13
13
  if (values[k] != null)
14
14
  a.push(values[k]);
15
15
  return a;
16
- // v => !(typeof v === 'number' && !keys.includes(String(v))),
17
16
  }, []);
18
17
  }
19
18
  const valObj = (Array.isArray(values) ? values : [values]).reduce((a, v) => {