@streamscloud/kit 0.12.0 → 0.13.0

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,4 +1,4 @@
1
1
  import type { MinNumberValidation, NumberValidation } from './types';
2
2
  import * as yup from 'yup';
3
- export declare const numberValidationSchema: (rules: NumberValidation) => yup.NumberSchema<number | undefined, yup.AnyObject, undefined, "">;
4
- export declare const minNumberValidationSchema: (rules: MinNumberValidation) => yup.NumberSchema<number | undefined, yup.AnyObject, undefined, "">;
3
+ export declare const numberValidationSchema: (rules: NumberValidation) => yup.NumberSchema<number | null | undefined, yup.AnyObject, undefined, "">;
4
+ export declare const minNumberValidationSchema: (rules: MinNumberValidation) => yup.NumberSchema<number | null | undefined, yup.AnyObject, undefined, "">;
@@ -2,10 +2,7 @@ import { ValidationLocalization } from './validation-localization';
2
2
  import * as yup from 'yup';
3
3
  export const numberValidationSchema = (rules) => {
4
4
  const msg = new ValidationLocalization();
5
- let schema = yup.number().typeError(msg.badFormat);
6
- if (rules.isRequired) {
7
- schema = schema.required(msg.required);
8
- }
5
+ let schema = yup.number().typeError(msg.badFormat).nullable();
9
6
  if (rules.minValue !== null) {
10
7
  const minValue = rules.minExclusive ? rules.minValue + 1 : rules.minValue;
11
8
  schema = schema.min(minValue, msg.min(minValue));
@@ -18,10 +15,7 @@ export const numberValidationSchema = (rules) => {
18
15
  };
19
16
  export const minNumberValidationSchema = (rules) => {
20
17
  const msg = new ValidationLocalization();
21
- let schema = yup.number().typeError(msg.badFormat);
22
- if (rules.isRequired) {
23
- schema = schema.required(msg.required);
24
- }
18
+ let schema = yup.number().typeError(msg.badFormat).nullable();
25
19
  if (rules.minValue !== null) {
26
20
  const minValue = rules.minExclusive ? rules.minValue + 1 : rules.minValue;
27
21
  schema = schema.min(minValue, msg.min(minValue));
@@ -6,14 +6,12 @@ export type TextWithFormatValidation = TextValidation & {
6
6
  format: string;
7
7
  };
8
8
  export type NumberValidation = {
9
- isRequired: boolean;
10
9
  minValue: number | null;
11
10
  maxValue: number | null;
12
11
  minExclusive: boolean;
13
12
  maxExclusive: boolean;
14
13
  };
15
14
  export type MinNumberValidation = {
16
- isRequired: boolean;
17
15
  minValue: number | null;
18
16
  minExclusive: boolean;
19
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamscloud/kit",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "author": "StreamsCloud",
5
5
  "repository": {
6
6
  "type": "git",