@bolttech/form-engine-core 1.0.2-beta.1 → 1.0.2

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.
Files changed (46) hide show
  1. package/index.d.ts +2314 -0
  2. package/index.esm.js +131 -81
  3. package/package.json +9 -10
  4. package/index.esm.d.ts +0 -1
  5. package/src/constants/constants.d.ts +0 -10
  6. package/src/formatters/creditCard.d.ts +0 -23
  7. package/src/formatters/custom.d.ts +0 -29
  8. package/src/formatters/handler.d.ts +0 -2
  9. package/src/formatters/regex.d.ts +0 -47
  10. package/src/formatters/splitter.d.ts +0 -17
  11. package/src/formatters/string.d.ts +0 -88
  12. package/src/helpers/SafeSubject.d.ts +0 -11
  13. package/src/helpers/creditCard.d.ts +0 -95
  14. package/src/helpers/helpers.d.ts +0 -67
  15. package/src/helpers/validation.d.ts +0 -27
  16. package/src/index.d.ts +0 -10
  17. package/src/interfaces/schema.d.ts +0 -112
  18. package/src/interfaces/state.d.ts +0 -22
  19. package/src/managers/field.d.ts +0 -326
  20. package/src/managers/form.d.ts +0 -346
  21. package/src/managers/formGroup.d.ts +0 -110
  22. package/src/managers/index.d.ts +0 -3
  23. package/src/masks/creditCard.d.ts +0 -60
  24. package/src/masks/generic.d.ts +0 -39
  25. package/src/masks/handler.d.ts +0 -2
  26. package/src/masks/string.d.ts +0 -99
  27. package/src/types/event.d.ts +0 -109
  28. package/src/types/form.d.ts +0 -55
  29. package/src/types/mapper.d.ts +0 -95
  30. package/src/types/schema.d.ts +0 -835
  31. package/src/types/template.d.ts +0 -50
  32. package/src/types/utility.d.ts +0 -6
  33. package/src/validations/creditCard.d.ts +0 -52
  34. package/src/validations/custom.d.ts +0 -25
  35. package/src/validations/date.d.ts +0 -79
  36. package/src/validations/document.d.ts +0 -25
  37. package/src/validations/handler.d.ts +0 -2
  38. package/src/validations/length.d.ts +0 -39
  39. package/src/validations/list.d.ts +0 -32
  40. package/src/validations/logical.d.ts +0 -75
  41. package/src/validations/multiple.d.ts +0 -31
  42. package/src/validations/namedRule.d.ts +0 -22
  43. package/src/validations/number.d.ts +0 -145
  44. package/src/validations/object.d.ts +0 -44
  45. package/src/validations/regex.d.ts +0 -217
  46. package/src/validations/string.d.ts +0 -53
@@ -1,50 +0,0 @@
1
- import { TEMPLATE_AVALIABLE_SCOPES } from '../constants/constants';
2
- import { TMutationEvents } from './event';
3
- /**
4
- * @type TSubscribedTemplates
5
- * Represents the subscribed templates for dynamic updates.
6
- *
7
- * @property {string} originExpression - The expression to evaluate.
8
- * @property {(typeof TEMPLATE_AVALIABLE_SCOPES)[number][]} originScopeKeys - Origin scope of the updated template value
9
- * @property {string[]} originPropertyKeys - The properties of the origin fields.
10
- * @property {string[]} originFieldKeys - The keys of the origin fields.
11
- * @property {string} destinationKey - The key of the destination field.
12
- * @property {string} destinationProperty - The property of the destination field.
13
- * @property {string[]} destinationPath - The path to the destination property.
14
- *
15
- * @example
16
- * ```typescript
17
- * const subscribedTemplates: TSubscribedTemplates = {
18
- * originExpression: 'originField1 + originField2',
19
- * originScopeKeys: ['field','field'],
20
- * originPropertyKeys: ['value', 'props'],
21
- * originFieldKeys: ['originField1', 'originField2'],
22
- * destinationKey: 'resultField',
23
- * destinationProperty: 'value',
24
- * destinationPath: ['path', 'to', 'resultField']
25
- * };
26
- * ```
27
- */
28
- type TSubscribedTemplates = {
29
- originExpression: string;
30
- originScopeKeys: (typeof TEMPLATE_AVALIABLE_SCOPES)[number][];
31
- originPropertyKeys: string[];
32
- originFieldKeys: string[];
33
- destinationKey: string;
34
- destinationProperty: string;
35
- destinationPath: string[];
36
- };
37
- /**
38
- * @type TTemplateEvent
39
- * Represents the event occuring on templates that changes property values.
40
- *
41
- * @property {(typeof TEMPLATE_AVALIABLE_SCOPES)[number]} scope - template scope triggering the event.
42
- * @property {string} key - field triggering the template refresh
43
- * @property {TMutationEvents} event - template event triggering the template refresh.
44
- */
45
- type TTemplateEvent = {
46
- scope: (typeof TEMPLATE_AVALIABLE_SCOPES)[number];
47
- key?: string;
48
- event: TMutationEvents;
49
- };
50
- export { TSubscribedTemplates, TTemplateEvent };
@@ -1,6 +0,0 @@
1
- import { TValidationMethods } from './schema';
2
- export type AllowOnly<T, K extends keyof T> = Pick<T, K> & {
3
- [P in keyof Omit<T, K>]?: never;
4
- };
5
- export type OneOf<T, K = keyof T> = K extends keyof T ? AllowOnly<T, K> : never;
6
- export type TValidationHandler = Record<string, (value: unknown, validations: TValidationMethods) => boolean>;
@@ -1,52 +0,0 @@
1
- import { TValidationMethods } from '../types/schema';
2
- /**
3
- * Validates if a given value is a valid credit card number based on predefined validation methods.
4
- *
5
- * @param value - The value to be validated as a credit card number.
6
- * @param validations - An object containing validation methods.
7
- * @returns `true` if the value is either falsy or does not match a valid credit card type, otherwise `false`.
8
- *
9
- * @example
10
- * ```typescript
11
- * import { isCreditCard } from './path/to/validationFunctions';
12
- * import { validationMethods } from './path/to/validationConfig';
13
- *
14
- * const isValid = isCreditCard('4111111111111111', validationMethods);
15
- * console.log(isValid); // Output: true or false based on validation
16
- * ```
17
- */
18
- export declare const isCreditCard: (value: unknown, validations: TValidationMethods) => boolean;
19
- /**
20
- * Validates if a given security code matches the expected length for a specified credit card type.
21
- *
22
- * @param value - The security code to be validated.
23
- * @param validations - An object containing validation methods, specifically with `isCreditCodeMatch` details.
24
- * @returns `true` if the value is either falsy or if the validation methods are not provided. Otherwise, it checks if the security code length matches the expected length for the card type.
25
- *
26
- * @example
27
- * ```typescript
28
- * import { isCreditCodeMatch } from './path/to/validationFunctions';
29
- * import { validationMethods } from './path/to/validationConfig';
30
- *
31
- * const isValid = isCreditCodeMatch('123', validationMethods);
32
- * console.log(isValid); // Output: true or false based on validation
33
- * ```
34
- */
35
- export declare const isCreditCodeMatch: (value: string, validations: TValidationMethods) => boolean;
36
- /**
37
- * Validates if a given value is a valid credit card number and checks if its length matches the expected lengths for the card type.
38
- *
39
- * @param value - The credit card number to be validated.
40
- * @param validations - An object containing validation methods, specifically with `isCreditCardAndLength` details.
41
- * @returns `true` if the value is either falsy or if the card number does not match any valid lengths for the card type, otherwise `false`.
42
- *
43
- * @example
44
- * ```typescript
45
- * import { isCreditCardAndLength } from './path/to/validationFunctions';
46
- * import { validationMethods } from './path/to/validationConfig';
47
- *
48
- * const isValid = isCreditCardAndLength('4111111111111111', validationMethods);
49
- * console.log(isValid); // Output: true or false based on validation
50
- * ```
51
- */
52
- export declare const isCreditCardAndLength: (value: string, validations: TValidationMethods) => boolean;
@@ -1,25 +0,0 @@
1
- import { TValidationMethods } from '../types/schema';
2
- /**
3
- * Executes a custom callback validation function if provided.
4
- *
5
- * @param value - The value to be validated.
6
- * @param validations - An object containing validation methods, including a custom callback function.
7
- * @returns `true` if the custom callback validation function returns `true`, otherwise `false`.
8
- *
9
- * @example
10
- * ```typescript
11
- * import { callback } from './path/to/validationFunctions';
12
- *
13
- * const validations = {
14
- * callback: (value) => typeof value === 'string' && value.length > 5
15
- * };
16
- *
17
- * // Or from a JSON config
18
- * const schema = {
19
- * validations: {
20
- * callback: (value) => typeof value === 'string' && value.length > 5
21
- * }
22
- * };
23
- * ```
24
- */
25
- export declare const callback: (value: unknown, validations: TValidationMethods) => boolean;
@@ -1,79 +0,0 @@
1
- import { TValidationMethods } from '../types/schema';
2
- /**
3
- * @function betweenDates
4
- * Validates if a date value falls between two specified dates.
5
- *
6
- * @param {string} value - The date value to be validated in string format.
7
- * @param {TValidationMethods} validations - The validation methods object containing the betweenDates validation rules.
8
- * @returns {boolean} - Returns `true` if the date value fails the betweenDates validation, otherwise `false`.
9
- *
10
- * @example
11
- * ```typescript
12
- * const validations = {
13
- * betweenDates: [
14
- * { origin: { value: '2023-01-01', format: 'yyyy-MM-dd' }, operator: '>=' },
15
- * { origin: { value: '2023-12-31', format: 'yyyy-MM-dd' }, operator: '<=' }
16
- * ]
17
- * };
18
- *
19
- * const result1 = betweenDates('2023-06-01', validations);
20
- * console.log(result1); // false (date is within the range)
21
- *
22
- * const result2 = betweenDates('2024-01-01', validations);
23
- * console.log(result2); // true (date is outside the range)
24
- * ```
25
- */
26
- export declare const betweenDates: (value: string, validations: TValidationMethods) => boolean;
27
- /**
28
- * @function date
29
- * Validates a date value based on various date conditions and intervals.
30
- *
31
- * @param {string} value - The date value to be validated in string format.
32
- * @param {TValidationMethods} validations - The validation methods object containing the date validation rules.
33
- * @returns {boolean} - Returns `true` if the date validation fails, otherwise `false`.
34
- *
35
- * @example
36
- * ```typescript
37
- * const validations = {
38
- * date: {
39
- * origin: {
40
- * value: '2023-01-01',
41
- * format: 'YYYY-MM-DD'
42
- * },
43
- * target: {
44
- * value: '2023-12-31',
45
- * format: 'YYYY-MM-DD'
46
- * },
47
- * operator: '<=',
48
- * onlyValidDate: true
49
- * }
50
- * };
51
- *
52
- * const result1 = date('2023-06-01', validations);
53
- * console.log(result1); // false (date is within the range)
54
- *
55
- * const result2 = date('2024-01-01', validations);
56
- * console.log(result2); // true (date is outside the range)
57
- * ```
58
- */
59
- export declare const date: (value: string, validations: TValidationMethods) => boolean;
60
- /**
61
- * @function validDate
62
- * Validates that a date string is a valid date according to the given format.
63
- *
64
- * @param {string} value - The date value to be validated in string format.
65
- * @param {TValidationMethods} validations - The validation methods object containing the validDate rule.
66
- * @returns {boolean} - Returns `true` if the date is not valid, otherwise `false`.
67
- *
68
- * @example
69
- * ```typescript
70
- * const validations = { validDate: 'MM-dd-yyyy' };
71
- *
72
- * const result1 = validDate('12-31-2023', validations);
73
- * console.log(result1); // false (date is valid)
74
- *
75
- * const result2 = validDate('02-30-2023', validations);
76
- * console.log(result2); // true (date is invalid)
77
- * ```
78
- */
79
- export declare const validDate: (value: string, validations: TValidationMethods) => boolean;
@@ -1,25 +0,0 @@
1
- import { TValidationMethods } from '../types/schema';
2
- /**
3
- * General validation function for various document types based on the provided validation methods.
4
- *
5
- * @param value - The document value to validate.
6
- * @param validations - An object containing validation methods.
7
- * @returns `true` if the document is valid, otherwise `false`.
8
- *
9
- * @example
10
- * ```typescript
11
- * import validateDocument from './path/to/validationFunctions';
12
- *
13
- * const validations = {
14
- * document: {
15
- * type: 'NIF',
16
- * locale: 'pt-PT'
17
- * }
18
- * };
19
- *
20
- * const isValid = validateDocument('123456789', validations);
21
- * console.log(isValid); // Output: true or false based on validation
22
- * ```
23
- */
24
- declare const _default: (value: string, validations: TValidationMethods) => boolean;
25
- export default _default;
@@ -1,2 +0,0 @@
1
- import { TValidationHandler } from '../types/utility';
2
- export declare const validations: TValidationHandler;
@@ -1,39 +0,0 @@
1
- import { TValidationMethods } from '../types/schema';
2
- /**
3
- * Validates the length of a value based on the provided validation rules.
4
- *
5
- * @param value - The value to be validated. Can be of any type but will be converted to a string for length validation.
6
- * @param validations - An object containing the length validation rules.
7
- * @returns `true` if the value meets the length validation rule, otherwise `false`.
8
- *
9
- * @example
10
- * ```typescript
11
- * import validateLength from './path/to/validationFunctions';
12
- *
13
- * const validations = {
14
- * length: {
15
- * target: 5,
16
- * rule: 'equal'
17
- * }
18
- * };
19
- *
20
- * const isValid = validateLength('hello', validations);
21
- * console.log(isValid); // Output: true
22
- *
23
- * // Using from a JSON config
24
- * const config = {
25
- * inputValue: 'test',
26
- * validations: {
27
- * length: {
28
- * target: 4,
29
- * rule: 'equal'
30
- * }
31
- * }
32
- * };
33
- *
34
- * const isValid = validateLength(config.inputValue, config.validations);
35
- * console.log(isValid); // Output: true or false based on validation
36
- * ```
37
- */
38
- declare const _default: (value: unknown, validations: TValidationMethods) => boolean;
39
- export default _default;
@@ -1,32 +0,0 @@
1
- import { TValidationMethods } from '../types/schema';
2
- /**
3
- * Checks if a value is included in the specified array within the validation rules.
4
- *
5
- * @param value - The value to be checked.
6
- * @param validations - An object containing validation methods, including an array of allowed values.
7
- * @returns `true` if the value is included in the array, otherwise `false`.
8
- *
9
- * @example
10
- * ```typescript
11
- * import { includes } from './path/to/validationFunctions';
12
- *
13
- * const validations = {
14
- * includes: ['apple', 'banana', 'cherry']
15
- * };
16
- *
17
- * const isValid = includes('banana', validations);
18
- * console.log(isValid); // Output: true
19
- *
20
- * // Using from a JSON config
21
- * const config = {
22
- * inputValue: 'apple',
23
- * validations: {
24
- * includes: ['apple', 'banana', 'cherry']
25
- * }
26
- * };
27
- *
28
- * const isValid = includes(config.inputValue, config.validations);
29
- * console.log(isValid); // Output: true or false based on validation
30
- * ```
31
- */
32
- export declare const includes: (value: unknown, validations: TValidationMethods) => boolean;
@@ -1,75 +0,0 @@
1
- import { TValidationMethods } from '../types/schema';
2
- /**
3
- * Validates that a value is required.
4
- *
5
- * @param {unknown} value - The value to be validated.
6
- * @param {TValidationMethods} validations - The validation methods object containing the required validation rule.
7
- * @returns {boolean} - Returns `true` if the value is required and is empty or not provided, otherwise `false`.
8
- *
9
- * @example
10
- * ```typescript
11
- * // Assume validations is an object with a required property
12
- * const validations = { required: true };
13
- *
14
- * // Returns true because the value is required and is empty
15
- * const result1 = required('', validations);
16
- * console.log(result1); // true
17
- *
18
- * // Returns false because the value is required and is provided
19
- * const result2 = required('text', validations);
20
- * console.log(result2); // false
21
- *
22
- * // Returns false because the required validation rule is not set
23
- * const result3 = required('', { required: false });
24
- * console.log(result3); // false
25
- * ```
26
- */
27
- export declare const required: (value: unknown, validations: TValidationMethods) => boolean;
28
- /**
29
- * Validates that a value matches a boolean rule. Useful with iVars property.
30
- *
31
- * @param _
32
- * @param {TValidationMethods} validations - The validation methods object containing the boolean validation rule.
33
- * @returns {boolean} - Returns `true` if the boolean validation rule is set and fails, otherwise `false`.
34
- *
35
- * @example
36
- * ```typescript
37
- * // Assume validations is an object with a bool property
38
- * const validations = { bool: true };
39
- *
40
- * // Returns true because the boolean validation rule is set to fail
41
- * const result1 = bool(null, validations);
42
- * console.log(result1); // true
43
- *
44
- * // Returns false because the boolean validation rule is not set
45
- * const result2 = bool(null, { bool: false });
46
- * console.log(result2); // false
47
- * ```
48
- */
49
- export declare const bool: (_: unknown, validations: TValidationMethods) => boolean;
50
- /**
51
- * Validates that a value exists. Useful with iVars property.
52
- *
53
- * @param {unknown} value - The value to be validated.
54
- * @param {TValidationMethods} validations - The validation methods object containing the exists validation rule.
55
- * @returns {boolean} - Returns `true` if the value does not exist when the exists rule is set, otherwise `false`.
56
- *
57
- * @example
58
- * ```typescript
59
- * // Assume validations is an object with an exists property
60
- * const validations = { exists: true };
61
- *
62
- * // Returns true because the value does not exist
63
- * const result1 = exists(null, validations);
64
- * console.log(result1); // true
65
- *
66
- * // Returns false because the value exists
67
- * const result2 = exists('text', validations);
68
- * console.log(result2); // false
69
- *
70
- * // Returns false because the exists validation rule is not set
71
- * const result3 = exists(null, { exists: false });
72
- * console.log(result3); // false
73
- * ```
74
- */
75
- export declare const exists: (value: unknown, validations: TValidationMethods) => boolean;
@@ -1,31 +0,0 @@
1
- import { TValidationMethods } from '../types/schema';
2
- /**
3
- * Validates that a value meets multiple validation rules.
4
- *
5
- * @param {number | string | boolean} value - The value to be validated.
6
- * @param {TValidationMethods} methods - The validation methods object containing the multipleValidations rule set.
7
- * @returns {boolean} - Returns `true` if the value meets the specified multiple validation rules, otherwise `false`.
8
- *
9
- * @example
10
- * ```typescript
11
- * // Assume validations is an object with a multipleValidations property
12
- * const validations = {
13
- * multipleValidations: {
14
- * rule: 'AND',
15
- * validations: {
16
- * required: true,
17
- * isNumber: true
18
- * }
19
- * }
20
- * };
21
- *
22
- * // Returns true because both required and isNumber validations pass
23
- * const result1 = multipleValidations(123, validations);
24
- * console.log(result1); // true
25
- *
26
- * // Returns false because the value is not a number
27
- * const result2 = multipleValidations('abc', validations);
28
- * console.log(result2); // false
29
- * ```
30
- */
31
- export declare const multipleValidations: (value: number | string | boolean, methods: TValidationMethods) => boolean;
@@ -1,22 +0,0 @@
1
- import { TValidationMethods } from '../types/schema';
2
- import { TValidationHandler } from '../types/utility';
3
- /**
4
- * Validates a given value based on specified validation methods inside a custom named validation.
5
- *
6
- * @param {unknown} value - The value to be validated.
7
- * @param {TValidationMethods} methods - The validation methods to be applied.
8
- * @param {TValidationHandler} validations - An object containing every validation methods to be executed.
9
- * @returns {boolean} - Returns true if any of the validation methods pass, otherwise false.
10
- *
11
- * @example
12
- * const value = 'example@example.com';
13
- * const methods = {
14
- * required: true,
15
- * email: true
16
- * };
17
- *
18
- * const isValid = validateValue(value, methods);
19
- * console.log(isValid); // Output: true
20
- */
21
- declare const _default: (value: unknown, methods: TValidationMethods, validations: TValidationHandler) => boolean;
22
- export default _default;
@@ -1,145 +0,0 @@
1
- import { TValidationMethods } from '../types/schema';
2
- /**
3
- * Validates if a value exceeds the maximum allowed value.
4
- *
5
- * @param value - The value to be checked.
6
- * @param validations - An object containing the maximum value for validation.
7
- * @returns `true` if the value exceeds the maximum, otherwise `false`.
8
- *
9
- * @example
10
- * ```typescript
11
- * import { max } from './path/to/validationFunctions';
12
- *
13
- * const validations = { max: 10 };
14
- *
15
- * const isValid = max(15, validations);
16
- * console.log(isValid); // Output: true
17
- *
18
- * // Using from a JSON config
19
- * const config = {
20
- * inputValue: '8',
21
- * validations: { max: 10 }
22
- * };
23
- *
24
- * const isValid = max(config.inputValue, config.validations);
25
- * console.log(isValid); // Output: false
26
- * ```
27
- */
28
- export declare const max: (value: unknown, validations: TValidationMethods) => boolean;
29
- /**
30
- * Validates if a value is less than the minimum allowed value.
31
- *
32
- * @param value - The value to be checked.
33
- * @param validations - An object containing the minimum value for validation.
34
- * @returns `true` if the value is less than the minimum, otherwise `false`.
35
- *
36
- * @example
37
- * ```typescript
38
- * import { min } from './path/to/validationFunctions';
39
- *
40
- * const validations = { min: 5 };
41
- *
42
- * const isValid = min(3, validations);
43
- * console.log(isValid); // Output: true
44
- *
45
- * // Using from a JSON config
46
- * const config = {
47
- * inputValue: '8',
48
- * validations: { min: 10 }
49
- * };
50
- *
51
- * const isValid = min(config.inputValue, config.validations);
52
- * console.log(isValid); // Output: true
53
- * ```
54
- */
55
- export declare const min: (value: unknown, validations: TValidationMethods) => boolean;
56
- /**
57
- * Validates if a value falls within a specified range.
58
- *
59
- * @param value - The value to be checked.
60
- * @param validations - An object containing the range (start and end) for validation.
61
- * @returns `true` if the value falls within the range, otherwise `false`.
62
- *
63
- * @example
64
- * ```typescript
65
- * import { between } from './path/to/validationFunctions';
66
- *
67
- * const validations = { between: { start: 5, end: 10 } };
68
- *
69
- * const isValid = between(7, validations);
70
- * console.log(isValid); // Output: true
71
- *
72
- * // Using from a JSON config
73
- * const config = {
74
- * inputValue: '4',
75
- * validations: { between: { start: 5, end: 10 } }
76
- * };
77
- *
78
- * const isValid = between(config.inputValue, config.validations);
79
- * console.log(isValid); // Output: false
80
- * ```
81
- */
82
- export declare const between: (value: unknown, validations: TValidationMethods) => boolean;
83
- /**
84
- * Checks if a given value is less than a specified threshold.
85
- *
86
- * @param value - The value to be checked. This value will be converted to a number.
87
- * @param validations - An object containing validation methods, specifically the `lessThan` property which holds the threshold value.
88
- * @returns Returns `false` if the `lessThan` threshold is not provided or if the value is not a valid number. Otherwise, returns `true` if the value is greater than or equal to the `lessThan` threshold.
89
- *
90
- * @example
91
- * ```typescript
92
- * const validations = { lessThan: 10 };
93
- * console.log(lessThan(5, validations)); // true
94
- * console.log(lessThan(15, validations)); // false
95
- * ```
96
- */
97
- export declare const lessThan: (value: unknown, validations: TValidationMethods) => boolean;
98
- /**
99
- * Checks if a given value is greater than a specified threshold.
100
- *
101
- * @param value - The value to be checked. This value will be converted to a number.
102
- * @param validations - An object containing validation methods, specifically the `greaterThan` property which holds the threshold value.
103
- * @returns Returns `false` if the `greaterThan` threshold is not provided or if the value is not a valid number. Otherwise, returns `true` if the value is less than or equal to the `greaterThan` threshold.
104
- *
105
- * @example
106
- * ```typescript
107
- * const validations = { greaterThan: 10 };
108
- * console.log(greaterThan(15, validations)); // true
109
- * console.log(greaterThan(5, validations)); // false
110
- * ```
111
- */
112
- export declare const greaterThan: (value: unknown, validations: TValidationMethods) => boolean;
113
- /**
114
- * Validates if a value contains sequential numbers.
115
- *
116
- * @param value - The value to be checked.
117
- * @param validations - An object containing the validation methods.
118
- * @returns `true` if the value contains sequential numbers, otherwise `false`.
119
- *
120
- * @example
121
- * ```typescript
122
- * import { sequential } from './path/to/validationFunctions';
123
- *
124
- * const validations = { sequential: true };
125
- *
126
- * const isValid = sequential('12345', validations);
127
- * console.log(isValid); // Output: true
128
- *
129
- * // Using in a React component
130
- * const MyComponent = ({ inputValue }) => {
131
- * const isValid = sequential(inputValue, validations);
132
- * return <div>{isValid ? 'Valid' : 'Invalid'}</div>;
133
- * };
134
- *
135
- * // Using from a JSON config
136
- * const config = {
137
- * inputValue: '98765',
138
- * validations: { sequential: true }
139
- * };
140
- *
141
- * const isValid = sequential(config.inputValue, config.validations);
142
- * console.log(isValid); // Output: true
143
- * ```
144
- */
145
- export declare const sequential: (value: unknown, validations: TValidationMethods) => boolean;
@@ -1,44 +0,0 @@
1
- import { TValidationMethods } from '../types/schema';
2
- /**
3
- * Validates that a value meets specified conditions.
4
- *
5
- * @param {number | string | boolean} value - The value to be validated.
6
- * @param {TValidationMethods} validations - The validation methods object containing the conditions validation rule.
7
- * @returns {boolean} - Returns `true` if the value meets the specified conditions, otherwise `false`.
8
- *
9
- * @example
10
- * ```typescript
11
- * // Assume validations is an object with a conditions property
12
- * const validations = {
13
- * conditions: {
14
- * rule: 'and',
15
- * set: [
16
- * { condition: '===', origin: 10, target: 10 },
17
- * { condition: '!==', origin: 5, target: 3 }
18
- * ]
19
- * }
20
- * };
21
- *
22
- * // Returns true because both conditions are met
23
- * const result1 = conditions(10, validations);
24
- * console.log(result1); // true
25
- *
26
- * // Returns false because the second condition is not met
27
- * const result2 = conditions(5, validations);
28
- * console.log(result2); // false
29
- *
30
- * // Returns true because at least one condition is met with 'or' rule
31
- * const orValidations = {
32
- * conditions: {
33
- * rule: 'or',
34
- * set: [
35
- * { condition: '===', origin: 10, target: 5 },
36
- * { condition: '!==', origin: 5, target: 3 }
37
- * ]
38
- * }
39
- * };
40
- * const result3 = conditions(10, orValidations);
41
- * console.log(result3); // true
42
- * ```
43
- */
44
- export declare const conditions: (value: number | string | boolean, validations: TValidationMethods) => boolean;