@rxap/forms 12.5.1-next.2 → 12.5.1-next.3

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.
@@ -42,7 +42,7 @@ export function _IsNumber({ message, options } = {}) {
42
42
  if (control.value === null) {
43
43
  return null;
44
44
  }
45
- if (!isNumber(control.value, options)) {
45
+ if (!isNumber(!(options === null || options === void 0 ? void 0 : options.strict) && typeof control.value === 'string' ? Number(control.value) : control.value, options)) {
46
46
  return {
47
47
  isNumber: {
48
48
  expected: 'A number value',
@@ -1 +1 @@
1
- {"version":3,"file":"is-number.js","sourceRoot":"","sources":["../../../../../../libs/forms/src/lib/validators/is-number.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc,EAAE,UAA2B,EAAE;;IACpE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,KAAK,CAAC;KACd;IAED,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,CAAC,QAAQ,EAAE;QAC7C,OAAO,MAAA,OAAO,CAAC,aAAa,mCAAI,KAAK,CAAC;KACvC;IAED,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACvB,OAAO,MAAA,OAAO,CAAC,QAAQ,mCAAI,KAAK,CAAC;KAClC;IAED,IAAI,OAAO,CAAC,gBAAgB,KAAK,SAAS,EAAE;QAC1C,IAAI,aAAa,GAAG,CAAC,CAAC;QACtB,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE;YACnB,aAAa,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAE,CAAC,CAAE,CAAC,MAAM,CAAC;SACzD;QACD,IAAI,aAAa,GAAG,OAAO,CAAC,gBAAgB,EAAE;YAC5C,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAwB;IAC/C,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,EAAE;QAC1B,OAAO,IAAI,CAAC;KACb;IACD,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE;QAChC,OAAO,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,4CAA4C,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;KACxG;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,EAAE,OAAO,EAAE,OAAO,KAAsD,EAAE;IAClG,OAAO,CAAC,OAAwB,EAA2B,EAAE;QAC3D,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,EAAE;YAC1B,OAAO,IAAI,CAAC;SACb;QACD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE;YACrC,OAAO;gBACL,QAAQ,EAAE;oBACR,QAAQ,EAAE,gBAAgB;oBAC1B,MAAM,EAAI,OAAO,CAAC,KAAK;oBACvB,OAAO;iBACR;aACF,CAAC;SACH;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n AbstractControl,\n ValidationErrors\n} from '@angular/forms';\n\n/**\n * Options to be passed to IsNumber decorator.\n */\nexport interface IsNumberOptions {\n allowNaN?: boolean;\n allowInfinity?: boolean;\n maxDecimalPlaces?: number;\n}\n\n/**\n * Checks if a given value is a number.\n */\nexport function isNumber(value: unknown, options: IsNumberOptions = {}): value is number {\n if (typeof value !== 'number') {\n return false;\n }\n\n if (value === Infinity || value === -Infinity) {\n return options.allowInfinity ?? false;\n }\n\n if (Number.isNaN(value)) {\n return options.allowNaN ?? false;\n }\n\n if (options.maxDecimalPlaces !== undefined) {\n let decimalPlaces = 0;\n if (value % 1 !== 0) {\n decimalPlaces = value.toString().split('.')[ 1 ].length;\n }\n if (decimalPlaces > options.maxDecimalPlaces) {\n return false;\n }\n }\n\n return Number.isFinite(value);\n}\n\n/**\n * @deprecated use RxapValidators.isNumber() instead\n * @param control\n * @constructor\n */\nexport function IsNumber(control: AbstractControl): ValidationErrors | null {\n if (control.value === null) {\n return null;\n }\n if (isNaN(Number(control.value))) {\n return { isNumber: { expected: 'A number or a string representing a number', actual: control.value } };\n }\n return null;\n}\n\nexport function _IsNumber({ message, options }: { message?: string, options?: IsNumberOptions } = {}) {\n return (control: AbstractControl): ValidationErrors | null => {\n if (control.value === null) {\n return null;\n }\n if (!isNumber(control.value, options)) {\n return {\n isNumber: {\n expected: 'A number value',\n actual: control.value,\n message\n }\n };\n }\n return null;\n };\n}\n"]}
1
+ {"version":3,"file":"is-number.js","sourceRoot":"","sources":["../../../../../../libs/forms/src/lib/validators/is-number.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc,EAAE,UAA2B,EAAE;;IACpE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,KAAK,CAAC;KACd;IAED,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,CAAC,QAAQ,EAAE;QAC7C,OAAO,MAAA,OAAO,CAAC,aAAa,mCAAI,KAAK,CAAC;KACvC;IAED,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACvB,OAAO,MAAA,OAAO,CAAC,QAAQ,mCAAI,KAAK,CAAC;KAClC;IAED,IAAI,OAAO,CAAC,gBAAgB,KAAK,SAAS,EAAE;QAC1C,IAAI,aAAa,GAAG,CAAC,CAAC;QACtB,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE;YACnB,aAAa,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAE,CAAC,CAAE,CAAC,MAAM,CAAC;SACzD;QACD,IAAI,aAAa,GAAG,OAAO,CAAC,gBAAgB,EAAE;YAC5C,OAAO,KAAK,CAAC;SACd;KACF;IAED,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAwB;IAC/C,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,EAAE;QAC1B,OAAO,IAAI,CAAC;KACb;IACD,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE;QAChC,OAAO,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,4CAA4C,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;KACxG;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,EAAE,OAAO,EAAE,OAAO,KAAsD,EAAE;IAClG,OAAO,CAAC,OAAwB,EAA2B,EAAE;QAC3D,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,EAAE;YAC1B,OAAO,IAAI,CAAC;SACb;QACD,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,CAAA,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE;YACrH,OAAO;gBACL,QAAQ,EAAE;oBACR,QAAQ,EAAE,gBAAgB;oBAC1B,MAAM,EAAI,OAAO,CAAC,KAAK;oBACvB,OAAO;iBACR;aACF,CAAC;SACH;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n AbstractControl,\n ValidationErrors\n} from '@angular/forms';\n\n/**\n * Options to be passed to IsNumber decorator.\n */\nexport interface IsNumberOptions {\n allowNaN?: boolean;\n allowInfinity?: boolean;\n maxDecimalPlaces?: number;\n strict?: boolean;\n}\n\n/**\n * Checks if a given value is a number.\n */\nexport function isNumber(value: unknown, options: IsNumberOptions = {}): value is number {\n if (typeof value !== 'number') {\n return false;\n }\n\n if (value === Infinity || value === -Infinity) {\n return options.allowInfinity ?? false;\n }\n\n if (Number.isNaN(value)) {\n return options.allowNaN ?? false;\n }\n\n if (options.maxDecimalPlaces !== undefined) {\n let decimalPlaces = 0;\n if (value % 1 !== 0) {\n decimalPlaces = value.toString().split('.')[ 1 ].length;\n }\n if (decimalPlaces > options.maxDecimalPlaces) {\n return false;\n }\n }\n\n return Number.isFinite(value);\n}\n\n/**\n * @deprecated use RxapValidators.isNumber() instead\n * @param control\n * @constructor\n */\nexport function IsNumber(control: AbstractControl): ValidationErrors | null {\n if (control.value === null) {\n return null;\n }\n if (isNaN(Number(control.value))) {\n return { isNumber: { expected: 'A number or a string representing a number', actual: control.value } };\n }\n return null;\n}\n\nexport function _IsNumber({ message, options }: { message?: string, options?: IsNumberOptions } = {}) {\n return (control: AbstractControl): ValidationErrors | null => {\n if (control.value === null) {\n return null;\n }\n if (!isNumber(!options?.strict && typeof control.value === 'string' ? Number(control.value) : control.value, options)) {\n return {\n isNumber: {\n expected: 'A number value',\n actual: control.value,\n message\n }\n };\n }\n return null;\n };\n}\n"]}
@@ -2258,7 +2258,7 @@ function _IsNumber({ message, options } = {}) {
2258
2258
  if (control.value === null) {
2259
2259
  return null;
2260
2260
  }
2261
- if (!isNumber(control.value, options)) {
2261
+ if (!isNumber(!(options === null || options === void 0 ? void 0 : options.strict) && typeof control.value === 'string' ? Number(control.value) : control.value, options)) {
2262
2262
  return {
2263
2263
  isNumber: {
2264
2264
  expected: 'A number value',