@arc-js/jon 0.0.1 → 0.0.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.
package/index.d.ts CHANGED
@@ -359,7 +359,7 @@ declare class AnyTypeSchema$1 extends JONDefaultSchema {
359
359
  validate(value: any): ValidationResult;
360
360
  private anyTypeValidation;
361
361
  }
362
- declare class FileSchema extends JONDefaultSchema {
362
+ declare class FileSchema$1 extends JONDefaultSchema {
363
363
  private _maxValue;
364
364
  private _minValue;
365
365
  private _lessValue;
@@ -395,7 +395,7 @@ declare const _default$1: {
395
395
  Enum: typeof EnumSchema$1;
396
396
  NotEnum: typeof NotEnumSchema$1;
397
397
  Array: typeof ArraySchema$1;
398
- File: typeof FileSchema;
398
+ File: typeof FileSchema$1;
399
399
  Object: typeof ObjectSchema$1;
400
400
  ChosenType: typeof ChosenTypeSchema$1;
401
401
  AnyType: typeof AnyTypeSchema$1;
@@ -410,6 +410,7 @@ declare const StringSchema: typeof StringSchema$1;
410
410
  declare const NumberSchema: typeof NumberSchema$1;
411
411
  declare const BooleanSchema: typeof BooleanSchema$1;
412
412
  declare const DateSchema: typeof DateSchema$1;
413
+ declare const FileSchema: typeof FileSchema$1;
413
414
  declare const EnumSchema: typeof EnumSchema$1;
414
415
  declare const NotEnumSchema: typeof NotEnumSchema$1;
415
416
  declare const ArraySchema: typeof ArraySchema$1;
@@ -424,10 +425,10 @@ declare const _default: {
424
425
  Enum: typeof EnumSchema$1;
425
426
  NotEnum: typeof NotEnumSchema$1;
426
427
  Array: typeof ArraySchema$1;
427
- File: typeof FileSchema;
428
+ File: typeof FileSchema$1;
428
429
  Object: typeof ObjectSchema$1;
429
430
  ChosenType: typeof ChosenTypeSchema$1;
430
431
  AnyType: typeof AnyTypeSchema$1;
431
432
  };
432
433
 
433
- export { AnyTypeSchema, ArraySchema, BooleanSchema, ChosenTypeSchema, DateSchema, EnumSchema, NotEnumSchema, NumberSchema, ObjectSchema, StringSchema, _default as default };
434
+ export { AnyTypeSchema, ArraySchema, BooleanSchema, ChosenTypeSchema, DateSchema, EnumSchema, FileSchema, NotEnumSchema, NumberSchema, ObjectSchema, StringSchema, _default as default };
package/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var Timez = require('@arc-js/timez');
6
- var Fodat = require('@arc-js/fodat');
5
+ var timez = require('@arc-js/timez');
6
+ var fodat = require('@arc-js/fodat');
7
7
 
8
8
  const NODEENV = 'development';
9
9
  const langs = ['en', 'fr'];
@@ -37,7 +37,7 @@ function defaultMapError(res, error, ruleName = undefined, label = undefined, la
37
37
  function isDatetimeFormat(value, format) {
38
38
  let res = false;
39
39
  try {
40
- res = Timez.parse(value, format).isCorrect();
40
+ res = timez.Timez.parse(value, format).isCorrect();
41
41
  }
42
42
  catch (err) {
43
43
  res = false;
@@ -63,14 +63,14 @@ function isDate(value, typeValue = undefined, dateFormat = dateTimeFormatInitial
63
63
  if (!!typeValue && !!typesPossible.includes(typeValue || '')) {
64
64
  dateFormat = defaultDateFormats[typeValue];
65
65
  }
66
- Timez.parse(value, dateFormat).isCorrect();
66
+ timez.Timez.parse(value, dateFormat).isCorrect();
67
67
  let res = ((typeof dateFormat === 'string' &&
68
68
  dateFormat.length > 0 &&
69
- Timez.parse(value, dateFormat).isCorrect()) || (typeValue === "string" &&
69
+ timez.Timez.parse(value, dateFormat).isCorrect()) || (typeValue === "string" &&
70
70
  typeof value === 'string' &&
71
71
  value.length > 0 &&
72
72
  dateFormat !== undefined &&
73
- Timez.parse(value, dateFormat).isCorrect()));
73
+ timez.Timez.parse(value, dateFormat).isCorrect()));
74
74
  return res;
75
75
  }
76
76
  function isString(value, typeValue = undefined, dateFormat = undefined) {
@@ -84,7 +84,7 @@ function isString(value, typeValue = undefined, dateFormat = undefined) {
84
84
  return ((!(typeof value === 'boolean') &&
85
85
  !value) || (typeof dateFormat === 'string' &&
86
86
  dateFormat.length > 0 &&
87
- Timez.parse(value, dateFormat).isCorrect()) || ((typeValue === 'other' ||
87
+ timez.Timez.parse(value, dateFormat).isCorrect()) || ((typeValue === 'other' ||
88
88
  typeof typeValue === 'undefined') &&
89
89
  typeof value in ['string', 'number', 'boolean']) || (typeValue === 'undefined' &&
90
90
  typeof value === 'undefined'));
@@ -1193,7 +1193,7 @@ let ObjectSchema$1 = class ObjectSchema extends JONDefaultSchema {
1193
1193
  const sanitizeFunct = (value) => {
1194
1194
  if (ruleFunct(value)) {
1195
1195
  if (value instanceof FormData) {
1196
- const resSanit = Fodat.transform(value);
1196
+ const resSanit = fodat.Fodat.transform(value);
1197
1197
  return (typeof resSanit === 'object' &&
1198
1198
  resSanit !== null &&
1199
1199
  !Array.isArray(resSanit)) ? resSanit : undefined;
@@ -2650,7 +2650,7 @@ let StringSchema$1 = class StringSchema extends JONDefaultSchema {
2650
2650
  else if (isDatetime ||
2651
2651
  isDate ||
2652
2652
  isTime) {
2653
- return Timez.parse(value, this._format).format(this._format);
2653
+ return timez.Timez.parse(value, this._format).format(this._format);
2654
2654
  }
2655
2655
  }
2656
2656
  else {
@@ -4385,12 +4385,12 @@ let DateSchema$1 = class DateSchema extends JONDefaultSchema {
4385
4385
  }
4386
4386
  let timezValue;
4387
4387
  if (typeof value === 'string' && isDatetimeFormat(value, this._format)) {
4388
- timezValue = Timez.parse(value, this._format);
4388
+ timezValue = timez.Timez.parse(value, this._format);
4389
4389
  }
4390
4390
  else if (value instanceof Date) {
4391
- timezValue = new Timez(value);
4391
+ timezValue = new timez.Timez(value);
4392
4392
  }
4393
- else if (value instanceof Timez) {
4393
+ else if (value instanceof timez.Timez) {
4394
4394
  timezValue = value;
4395
4395
  }
4396
4396
  else {
@@ -4429,7 +4429,7 @@ let DateSchema$1 = class DateSchema extends JONDefaultSchema {
4429
4429
  }
4430
4430
  min(minValue) {
4431
4431
  const rule = (valueInitial) => {
4432
- let minDate = Timez.parse(minValue, this._format);
4432
+ let minDate = timez.Timez.parse(minValue, this._format);
4433
4433
  if (minDate.isCorrect() && !!this._timezone) {
4434
4434
  minDate = minDate.setTimezone(this._timezone);
4435
4435
  }
@@ -4440,7 +4440,7 @@ let DateSchema$1 = class DateSchema extends JONDefaultSchema {
4440
4440
  if (!isNotNull(value)) {
4441
4441
  return true;
4442
4442
  }
4443
- let valueDate = Timez.parse(value, this._format);
4443
+ let valueDate = timez.Timez.parse(value, this._format);
4444
4444
  if (valueDate.isCorrect() && !!this._timezone) {
4445
4445
  valueDate = valueDate.setTimezone(this._timezone);
4446
4446
  }
@@ -4459,8 +4459,8 @@ let DateSchema$1 = class DateSchema extends JONDefaultSchema {
4459
4459
  let errorMessage = `${labelSTR} must be at least ${minDate.format()}`;
4460
4460
  if (this._maxValue !== undefined) {
4461
4461
  errorMessage = {
4462
- 'fr': `${labelSTR} doit être compris entre ${minDate.format()} et ${Timez.parse(this._maxValue).format()}`,
4463
- 'en': `${labelSTR} must be between ${minDate.format()} and ${Timez.parse(this._maxValue).format()}`,
4462
+ 'fr': `${labelSTR} doit être compris entre ${minDate.format()} et ${timez.Timez.parse(this._maxValue).format()}`,
4463
+ 'en': `${labelSTR} must be between ${minDate.format()} and ${timez.Timez.parse(this._maxValue).format()}`,
4464
4464
  }[this.get_lang()] || errorMessage;
4465
4465
  }
4466
4466
  else {
@@ -4489,7 +4489,7 @@ let DateSchema$1 = class DateSchema extends JONDefaultSchema {
4489
4489
  }
4490
4490
  max(maxValue) {
4491
4491
  const rule = (valueInitial) => {
4492
- let maxDate = Timez.parse(maxValue, this._format);
4492
+ let maxDate = timez.Timez.parse(maxValue, this._format);
4493
4493
  if (maxDate.isCorrect() && !!this._timezone) {
4494
4494
  maxDate = maxDate.setTimezone(this._timezone);
4495
4495
  }
@@ -4500,7 +4500,7 @@ let DateSchema$1 = class DateSchema extends JONDefaultSchema {
4500
4500
  if (!isNotNull(value)) {
4501
4501
  return true;
4502
4502
  }
4503
- let valueDate = Timez.parse(value, this._format);
4503
+ let valueDate = timez.Timez.parse(value, this._format);
4504
4504
  if (valueDate.isCorrect() && !!this._timezone) {
4505
4505
  valueDate = valueDate.setTimezone(this._timezone);
4506
4506
  }
@@ -4552,7 +4552,7 @@ let DateSchema$1 = class DateSchema extends JONDefaultSchema {
4552
4552
  }
4553
4553
  less(lessValue) {
4554
4554
  const rule = (valueInitial) => {
4555
- let lessDate = Timez.parse(lessValue, this._format);
4555
+ let lessDate = timez.Timez.parse(lessValue, this._format);
4556
4556
  if (lessDate.isCorrect() && !!this._timezone) {
4557
4557
  lessDate = lessDate.setTimezone(this._timezone);
4558
4558
  }
@@ -4563,7 +4563,7 @@ let DateSchema$1 = class DateSchema extends JONDefaultSchema {
4563
4563
  if (!isNotNull(value)) {
4564
4564
  return true;
4565
4565
  }
4566
- let valueDate = Timez.parse(value, this._format);
4566
+ let valueDate = timez.Timez.parse(value, this._format);
4567
4567
  if (valueDate.isCorrect() && !!this._timezone) {
4568
4568
  valueDate = valueDate.setTimezone(this._timezone);
4569
4569
  }
@@ -4615,7 +4615,7 @@ let DateSchema$1 = class DateSchema extends JONDefaultSchema {
4615
4615
  }
4616
4616
  greater(greaterValue) {
4617
4617
  const rule = (valueInitial) => {
4618
- let greaterDate = Timez.parse(greaterValue, this._format);
4618
+ let greaterDate = timez.Timez.parse(greaterValue, this._format);
4619
4619
  if (greaterDate.isCorrect() && !!this._timezone) {
4620
4620
  greaterDate = greaterDate.setTimezone(this._timezone);
4621
4621
  }
@@ -4626,7 +4626,7 @@ let DateSchema$1 = class DateSchema extends JONDefaultSchema {
4626
4626
  if (!isNotNull(value)) {
4627
4627
  return true;
4628
4628
  }
4629
- let valueDate = Timez.parse(value, this._format);
4629
+ let valueDate = timez.Timez.parse(value, this._format);
4630
4630
  if (valueDate.isCorrect() && !!this._timezone) {
4631
4631
  valueDate = valueDate.setTimezone(this._timezone);
4632
4632
  }
@@ -4678,7 +4678,7 @@ let DateSchema$1 = class DateSchema extends JONDefaultSchema {
4678
4678
  }
4679
4679
  equalTo(equalValue) {
4680
4680
  const rule = (valueInitial) => {
4681
- let equalDate = Timez.parse(equalValue, this._format);
4681
+ let equalDate = timez.Timez.parse(equalValue, this._format);
4682
4682
  if (equalDate.isCorrect() && !!this._timezone) {
4683
4683
  equalDate = equalDate.setTimezone(this._timezone);
4684
4684
  }
@@ -4689,7 +4689,7 @@ let DateSchema$1 = class DateSchema extends JONDefaultSchema {
4689
4689
  if (!isNotNull(value)) {
4690
4690
  return true;
4691
4691
  }
4692
- let valueDate = Timez.parse(value, this._format);
4692
+ let valueDate = timez.Timez.parse(value, this._format);
4693
4693
  if (valueDate.isCorrect() && !!this._timezone) {
4694
4694
  valueDate = valueDate.setTimezone(this._timezone);
4695
4695
  }
@@ -4940,7 +4940,7 @@ let AnyTypeSchema$1 = class AnyTypeSchema extends JONDefaultSchema {
4940
4940
  }
4941
4941
  }
4942
4942
  };
4943
- class FileSchema extends JONDefaultSchema {
4943
+ let FileSchema$1 = class FileSchema extends JONDefaultSchema {
4944
4944
  constructor(lang = 'fr') {
4945
4945
  super(lang);
4946
4946
  this._maxValue = undefined;
@@ -5358,7 +5358,7 @@ class FileSchema extends JONDefaultSchema {
5358
5358
  const fileName = `${baseName}-${Date.now()}.${ext}`;
5359
5359
  return new File([u8arr], fileName, { type: mime });
5360
5360
  }
5361
- }
5361
+ };
5362
5362
  var JONSchemas = {
5363
5363
  'String': StringSchema$1,
5364
5364
  'Number': NumberSchema$1,
@@ -5367,7 +5367,7 @@ var JONSchemas = {
5367
5367
  'Enum': EnumSchema$1,
5368
5368
  'NotEnum': NotEnumSchema$1,
5369
5369
  'Array': ArraySchema$1,
5370
- 'File': FileSchema,
5370
+ 'File': FileSchema$1,
5371
5371
  'Object': ObjectSchema$1,
5372
5372
  'ChosenType': ChosenTypeSchema$1,
5373
5373
  'AnyType': AnyTypeSchema$1,
@@ -5380,6 +5380,7 @@ const StringSchema = JONSchemas.String;
5380
5380
  const NumberSchema = JONSchemas.Number;
5381
5381
  const BooleanSchema = JONSchemas.Boolean;
5382
5382
  const DateSchema = JONSchemas.Date;
5383
+ const FileSchema = JONSchemas.File;
5383
5384
  const EnumSchema = JONSchemas.Enum;
5384
5385
  const NotEnumSchema = JONSchemas.NotEnum;
5385
5386
  const ArraySchema = JONSchemas.Array;
@@ -5394,6 +5395,7 @@ exports.BooleanSchema = BooleanSchema;
5394
5395
  exports.ChosenTypeSchema = ChosenTypeSchema;
5395
5396
  exports.DateSchema = DateSchema;
5396
5397
  exports.EnumSchema = EnumSchema;
5398
+ exports.FileSchema = FileSchema;
5397
5399
  exports.NotEnumSchema = NotEnumSchema;
5398
5400
  exports.NumberSchema = NumberSchema;
5399
5401
  exports.ObjectSchema = ObjectSchema;
package/index.min.d.ts CHANGED
@@ -359,7 +359,7 @@ declare class AnyTypeSchema$1 extends JONDefaultSchema {
359
359
  validate(value: any): ValidationResult;
360
360
  private anyTypeValidation;
361
361
  }
362
- declare class FileSchema extends JONDefaultSchema {
362
+ declare class FileSchema$1 extends JONDefaultSchema {
363
363
  private _maxValue;
364
364
  private _minValue;
365
365
  private _lessValue;
@@ -395,7 +395,7 @@ declare const _default$1: {
395
395
  Enum: typeof EnumSchema$1;
396
396
  NotEnum: typeof NotEnumSchema$1;
397
397
  Array: typeof ArraySchema$1;
398
- File: typeof FileSchema;
398
+ File: typeof FileSchema$1;
399
399
  Object: typeof ObjectSchema$1;
400
400
  ChosenType: typeof ChosenTypeSchema$1;
401
401
  AnyType: typeof AnyTypeSchema$1;
@@ -410,6 +410,7 @@ declare const StringSchema: typeof StringSchema$1;
410
410
  declare const NumberSchema: typeof NumberSchema$1;
411
411
  declare const BooleanSchema: typeof BooleanSchema$1;
412
412
  declare const DateSchema: typeof DateSchema$1;
413
+ declare const FileSchema: typeof FileSchema$1;
413
414
  declare const EnumSchema: typeof EnumSchema$1;
414
415
  declare const NotEnumSchema: typeof NotEnumSchema$1;
415
416
  declare const ArraySchema: typeof ArraySchema$1;
@@ -424,10 +425,10 @@ declare const _default: {
424
425
  Enum: typeof EnumSchema$1;
425
426
  NotEnum: typeof NotEnumSchema$1;
426
427
  Array: typeof ArraySchema$1;
427
- File: typeof FileSchema;
428
+ File: typeof FileSchema$1;
428
429
  Object: typeof ObjectSchema$1;
429
430
  ChosenType: typeof ChosenTypeSchema$1;
430
431
  AnyType: typeof AnyTypeSchema$1;
431
432
  };
432
433
 
433
- export { AnyTypeSchema, ArraySchema, BooleanSchema, ChosenTypeSchema, DateSchema, EnumSchema, NotEnumSchema, NumberSchema, ObjectSchema, StringSchema, _default as default };
434
+ export { AnyTypeSchema, ArraySchema, BooleanSchema, ChosenTypeSchema, DateSchema, EnumSchema, FileSchema, NotEnumSchema, NumberSchema, ObjectSchema, StringSchema, _default as default };