@fiddle-digital/string-tune 1.1.39 → 1.1.40

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/dist/index.d.mts CHANGED
@@ -1005,20 +1005,41 @@ declare class RuleParserTool implements IStringTool<RuleParserInput, RuleParserR
1005
1005
  process({ value }: RuleParserInput): RuleParserResult[];
1006
1006
  }
1007
1007
 
1008
+ interface ValidationContext {
1009
+ fieldKey?: string;
1010
+ values?: Record<string, any>;
1011
+ getValue?: (key: string) => any;
1012
+ }
1008
1013
  interface ValidateInput {
1009
1014
  rules: RuleParserResult[];
1010
1015
  value: any;
1011
1016
  type?: "input" | "beforeinput";
1017
+ context?: ValidationContext;
1012
1018
  }
1013
1019
  interface ValidationResult {
1014
1020
  valid: boolean;
1015
1021
  errors: string[];
1016
1022
  }
1023
+ type ValidatorFn = (value: any, params?: string[], context?: ValidationContext) => boolean;
1017
1024
  declare class ValidationTool implements IStringTool<ValidateInput, ValidationResult> {
1018
- process({ rules, value, type }: ValidateInput): ValidationResult;
1019
- inputValidators: Record<string, (value: any, ...params: string[]) => boolean>;
1020
- beforeInputValidators: Record<string, (value: any, ...params: string[]) => boolean>;
1025
+ process({ rules, value, type, context }: ValidateInput): ValidationResult;
1026
+ inputValidators: Record<string, ValidatorFn>;
1027
+ beforeInputValidators: Record<string, ValidatorFn>;
1021
1028
  getErrorMessage(key: string, params?: string[]): string;
1029
+ private validateMimes;
1030
+ private validateMaxSize;
1031
+ private extractFiles;
1032
+ private isMimeAllowed;
1033
+ private getFileExtension;
1034
+ private compareDates;
1035
+ private resolveDateReference;
1036
+ private toDate;
1037
+ private testByRegex;
1038
+ private normalizeRegex;
1039
+ private getContextValue;
1040
+ private areValuesEqual;
1041
+ private isIPv4;
1042
+ private isIPv6;
1022
1043
  }
1023
1044
 
1024
1045
  /**
@@ -1932,12 +1953,37 @@ declare class StringSequence extends StringModule {
1932
1953
  private setSequenceState;
1933
1954
  }
1934
1955
 
1956
+ type FormField = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
1935
1957
  declare class StringForm extends StringModule {
1936
1958
  constructor(context: StringContext);
1937
1959
  initializeObject(globalId: number, object: StringObject, element: HTMLElement, attributes: Record<string, any>): void;
1938
1960
  onObjectConnected(object: StringObject): void;
1939
- getInputKey(field: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, idx: number): string;
1940
- getFieldValue(field: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement): any;
1961
+ onDOMMutate(added: NodeList, removed: NodeList): void;
1962
+ private applyValidationState;
1963
+ private getInteractiveFields;
1964
+ private getFieldRules;
1965
+ private registerField;
1966
+ private unregisterField;
1967
+ private collectInteractiveFieldsFromNode;
1968
+ private handleMutationAdditions;
1969
+ private handleMutationRemovals;
1970
+ private getFormStateByContainment;
1971
+ private getFormStateByReference;
1972
+ private buildFormState;
1973
+ private registerFieldIndex;
1974
+ private getFieldIndex;
1975
+ private shouldValidateField;
1976
+ private supportsBeforeInputValidation;
1977
+ private requiresContext;
1978
+ private buildContext;
1979
+ private static readonly beforeInputRuleKeys;
1980
+ private static readonly crossFieldRuleKeys;
1981
+ private static readonly serviceAttributePrefixes;
1982
+ getInputKey(field: FormField, idx: number): string;
1983
+ getFieldValue(field: FormField): any;
1984
+ private isServiceFieldAttribute;
1985
+ private isFormFieldElement;
1986
+ private getInputEventType;
1941
1987
  }
1942
1988
 
1943
1989
  declare class StringScroller extends StringModule {
package/dist/index.d.ts CHANGED
@@ -1005,20 +1005,41 @@ declare class RuleParserTool implements IStringTool<RuleParserInput, RuleParserR
1005
1005
  process({ value }: RuleParserInput): RuleParserResult[];
1006
1006
  }
1007
1007
 
1008
+ interface ValidationContext {
1009
+ fieldKey?: string;
1010
+ values?: Record<string, any>;
1011
+ getValue?: (key: string) => any;
1012
+ }
1008
1013
  interface ValidateInput {
1009
1014
  rules: RuleParserResult[];
1010
1015
  value: any;
1011
1016
  type?: "input" | "beforeinput";
1017
+ context?: ValidationContext;
1012
1018
  }
1013
1019
  interface ValidationResult {
1014
1020
  valid: boolean;
1015
1021
  errors: string[];
1016
1022
  }
1023
+ type ValidatorFn = (value: any, params?: string[], context?: ValidationContext) => boolean;
1017
1024
  declare class ValidationTool implements IStringTool<ValidateInput, ValidationResult> {
1018
- process({ rules, value, type }: ValidateInput): ValidationResult;
1019
- inputValidators: Record<string, (value: any, ...params: string[]) => boolean>;
1020
- beforeInputValidators: Record<string, (value: any, ...params: string[]) => boolean>;
1025
+ process({ rules, value, type, context }: ValidateInput): ValidationResult;
1026
+ inputValidators: Record<string, ValidatorFn>;
1027
+ beforeInputValidators: Record<string, ValidatorFn>;
1021
1028
  getErrorMessage(key: string, params?: string[]): string;
1029
+ private validateMimes;
1030
+ private validateMaxSize;
1031
+ private extractFiles;
1032
+ private isMimeAllowed;
1033
+ private getFileExtension;
1034
+ private compareDates;
1035
+ private resolveDateReference;
1036
+ private toDate;
1037
+ private testByRegex;
1038
+ private normalizeRegex;
1039
+ private getContextValue;
1040
+ private areValuesEqual;
1041
+ private isIPv4;
1042
+ private isIPv6;
1022
1043
  }
1023
1044
 
1024
1045
  /**
@@ -1932,12 +1953,37 @@ declare class StringSequence extends StringModule {
1932
1953
  private setSequenceState;
1933
1954
  }
1934
1955
 
1956
+ type FormField = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
1935
1957
  declare class StringForm extends StringModule {
1936
1958
  constructor(context: StringContext);
1937
1959
  initializeObject(globalId: number, object: StringObject, element: HTMLElement, attributes: Record<string, any>): void;
1938
1960
  onObjectConnected(object: StringObject): void;
1939
- getInputKey(field: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, idx: number): string;
1940
- getFieldValue(field: HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement): any;
1961
+ onDOMMutate(added: NodeList, removed: NodeList): void;
1962
+ private applyValidationState;
1963
+ private getInteractiveFields;
1964
+ private getFieldRules;
1965
+ private registerField;
1966
+ private unregisterField;
1967
+ private collectInteractiveFieldsFromNode;
1968
+ private handleMutationAdditions;
1969
+ private handleMutationRemovals;
1970
+ private getFormStateByContainment;
1971
+ private getFormStateByReference;
1972
+ private buildFormState;
1973
+ private registerFieldIndex;
1974
+ private getFieldIndex;
1975
+ private shouldValidateField;
1976
+ private supportsBeforeInputValidation;
1977
+ private requiresContext;
1978
+ private buildContext;
1979
+ private static readonly beforeInputRuleKeys;
1980
+ private static readonly crossFieldRuleKeys;
1981
+ private static readonly serviceAttributePrefixes;
1982
+ getInputKey(field: FormField, idx: number): string;
1983
+ getFieldValue(field: FormField): any;
1984
+ private isServiceFieldAttribute;
1985
+ private isFormFieldElement;
1986
+ private getInputEventType;
1941
1987
  }
1942
1988
 
1943
1989
  declare class StringScroller extends StringModule {