@arsedizioni/ars-utils 22.5.72 → 22.6.75

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arsedizioni/ars-utils",
3
- "version": "22.5.72",
3
+ "version": "22.6.75",
4
4
  "author": {
5
5
  "email": "software@arsedizioni.it",
6
6
  "name": "Fabio Buscaroli, Alberto Doria"
@@ -438,6 +438,25 @@ declare function dateRange<TValue extends string | Date | null | undefined, TPat
438
438
  * @returns void
439
439
  */
440
440
  declare function notFuture<TPathKind extends PathKind = PathKind.Root>(path: SchemaPath<string, SchemaPathRules.Supported, TPathKind>, config?: ArsValidatorConfig<string, TPathKind>): void;
441
+ /**
442
+ * Requires the value to be a date that is not in the past.
443
+ *
444
+ * The mirror image of {@link notFuture}, for the fields that can only look forward: an expiry, a
445
+ * deadline, the date of a course still to be held. Today counts as valid — the comparison is made
446
+ * on the start of the day, so a date picked this afternoon for today does not become invalid
447
+ * because the clock has moved on.
448
+ *
449
+ * Like {@link date}, and unlike the older {@link notFuture}, it accepts both the `Date` a Material
450
+ * datepicker writes into the model and the text of a plain input. An empty value passes: saying
451
+ * "obbligatorio" is the job of `required()`.
452
+ *
453
+ * @param path - Path of the field to validate.
454
+ * @param config - Optional message override and `when` condition.
455
+ * @returns void
456
+ * @example
457
+ * const f = form(this.model, p => { required(p.scadenza); notPast(p.scadenza); });
458
+ */
459
+ declare function notPast<TValue extends string | Date | null | undefined, TPathKind extends PathKind = PathKind.Root>(path: SchemaPath<TValue, SchemaPathRules.Supported, TPathKind>, config?: ArsValidatorConfig<TValue, TPathKind>): void;
441
460
  /**
442
461
  * Requires the value to be a well-formed URL. An empty value passes, as everywhere else here.
443
462
  *
@@ -538,6 +557,46 @@ declare function equals<TValue, TPathKind extends PathKind = PathKind.Root>(path
538
557
  * @returns void
539
558
  */
540
559
  declare function otp<TPathKind extends PathKind = PathKind.Root>(path: SchemaPath<string, SchemaPathRules.Supported, TPathKind>, config?: ArsValidatorConfig<string, TPathKind>): void;
560
+ /**
561
+ * Requires the value to be a valid Italian VAT number (partita IVA).
562
+ *
563
+ * Eleven digits whose last one is the check digit of D.P.R. 633/72, so a mistyped or invented
564
+ * number is caught here rather than by the backend that will refuse the invoice. An `IT` prefix
565
+ * and the spacing of a pasted value are tolerated, because that is the shape the number arrives
566
+ * in; what is stored is still whatever the user typed, since this rule only judges.
567
+ *
568
+ * An empty value passes, as everywhere else here: declaring the field mandatory is `required()`'s
569
+ * job.
570
+ *
571
+ * @param path - Path of the field to validate.
572
+ * @param config - Optional message override and `when` condition.
573
+ * @returns void
574
+ * @example
575
+ * const f = form(this.model, p => { required(p.partitaIva); italianVat(p.partitaIva); });
576
+ */
577
+ declare function italianVat<TPathKind extends PathKind = PathKind.Root>(path: SchemaPath<string, SchemaPathRules.Supported, TPathKind>, config?: ArsValidatorConfig<string, TPathKind>): void;
578
+ /**
579
+ * Requires the value to be a valid Italian fiscal code (codice fiscale).
580
+ *
581
+ * Both shapes a registry form receives are accepted: the sixteen-character code of a natural
582
+ * person, control character recomputed and compared, and the eleven digits of a company or a
583
+ * public body, whose fiscal code IS its VAT number. Nothing has to tell the rule which one is
584
+ * coming — the value says it by its own length.
585
+ *
586
+ * Codes altered by an "omocodia" substitution (digits replaced by letters when two people would
587
+ * otherwise share a code) are accepted: they are issued by the Agenzia delle Entrate and rejecting
588
+ * them is the classic way a form turns away a real person.
589
+ *
590
+ * An empty value passes. Pair with `required()` when the field is mandatory, and reach for
591
+ * {@link italianVat} instead on a field that is specifically a VAT number.
592
+ *
593
+ * @param path - Path of the field to validate.
594
+ * @param config - Optional message override and `when` condition.
595
+ * @returns void
596
+ * @example
597
+ * const f = form(this.model, p => { required(p.codiceFiscale); italianFiscalCode(p.codiceFiscale); });
598
+ */
599
+ declare function italianFiscalCode<TPathKind extends PathKind = PathKind.Root>(path: SchemaPath<string, SchemaPathRules.Supported, TPathKind>, config?: ArsValidatorConfig<string, TPathKind>): void;
541
600
  /** Helpers around signal forms that are not validators themselves. */
542
601
  declare class SignalsUtils {
543
602
  /**
@@ -558,5 +617,5 @@ declare class SignalsUtils {
558
617
  }[], message?: string): string | undefined;
559
618
  }
560
619
 
561
- export { ARS_VALIDATOR_MESSAGES, EmailsValidatorDirective, EqualsValidatorDirective, FileSizeValidatorDirective, GuidValidatorDirective, MIN_VALID_YEAR, MaxTermsValidatorDirective, NotEmptyValidatorDirective, NotEqualValidatorDirective, NotFutureValidatorDirective, PasswordValidatorDirective, SignalsUtils, SqlDateValidatorDirective, TimeValidatorDirective, UrlValidatorDirective, ValidIfDirective, ValidatorDirective, date, dateRange, emails, equals, fileSize, guid, maxTerms, notEmpty, notEqual, notFuture, otp, password, sqlDate, time, url, validIf };
620
+ export { ARS_VALIDATOR_MESSAGES, EmailsValidatorDirective, EqualsValidatorDirective, FileSizeValidatorDirective, GuidValidatorDirective, MIN_VALID_YEAR, MaxTermsValidatorDirective, NotEmptyValidatorDirective, NotEqualValidatorDirective, NotFutureValidatorDirective, PasswordValidatorDirective, SignalsUtils, SqlDateValidatorDirective, TimeValidatorDirective, UrlValidatorDirective, ValidIfDirective, ValidatorDirective, date, dateRange, emails, equals, fileSize, guid, italianFiscalCode, italianVat, maxTerms, notEmpty, notEqual, notFuture, notPast, otp, password, sqlDate, time, url, validIf };
562
621
  export type { ArsValidatorConfig };