skyflow-js 1.36.2 → 1.36.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/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.36.3] - 2024-08-12
6
+ ### Fixed
7
+ - `update` method not working while updating custom validation rules.
8
+
9
+ ## [1.36.2] - 2024-07-31
10
+ ### Added
11
+ - Custom error message support for prebuilt collect elements.
12
+
13
+ ### Fixed
14
+ - Input error for card number when pasting a valid VISA card number by clearing the existing AMEX card number
15
+ - Remove format from copy text in card number element in JS SDK
16
+ - Hide copy icon when data is invalid in collect elements in JS SDK
17
+ - Change MasterCard to Mastercard in card brand choice dropdown
18
+
19
+ ## [1.36.1] - 2024-07-02
20
+ ### Fixed
21
+ - Restrict file types to upload
22
+
5
23
  ## [1.36.0] - 2024-05-08
6
24
  ### Added
7
25
  - card brand choice support for card number element.
package/README.md CHANGED
@@ -1130,6 +1130,48 @@ cardNumber.setError('custom error');
1130
1130
  cardNumber.resetError();
1131
1131
  ```
1132
1132
 
1133
+ ### Override default error Messages
1134
+
1135
+ You can override the default error messages with custom ones by using `setErrorOverride`. This is especially useful to override default error messages in non-English languages.
1136
+
1137
+ `setErrorOverride(message: string)`
1138
+
1139
+ `setErrorOverride` overrides the default error message. When the value is invalid, the error resets automatically when the value becomes valid.
1140
+
1141
+ ##### Sample code snippet for setErrorOverride
1142
+
1143
+ ```javascript
1144
+ const container = skyflowClient.container(Skyflow.ContainerType.COLLECT);
1145
+
1146
+ const cardNumber = container.create({
1147
+ table: 'pii_fields',
1148
+ column: 'primary_card.card_number',
1149
+ type: Skyflow.ElementType.CARD_NUMBER,
1150
+ });
1151
+
1152
+ // override default error.
1153
+ cardHolderNameElement.on(Skyflow.EventName.BLUR, state=>{
1154
+ if(state.isEmpty) {
1155
+ //can override the message when the field is required and empty
1156
+ cardHolderNameElement.setErrorOverride('custom error for required');
1157
+ } else if(!state.isValid) {
1158
+ //can override the message when the input is invalid
1159
+ cardHolderName.setErrorOverride('custom error for invalid');
1160
+ }
1161
+ });
1162
+ ```
1163
+
1164
+ ##### Difference between setError and setErrorOverride:
1165
+
1166
+ - `setError` sets the error state on the collect element, regardless of the element's state and value (valid or invalid). Once you call `setError`, the element remains in the error state until you call `resetError`. Use `setError` to set the error state on collect element based on server-side validations.
1167
+
1168
+ - `setErrorOverride` overrides the default error message. The error message resets automatically once the value becomes valid. Use `setErrorOverride` to change the default error message for a collect element.
1169
+
1170
+ **Note**:
1171
+ - `setErrorOverride` can only override default error messages.
1172
+ - `setErrorOverride` can only be used in BLUR event listener as shown in the earlier example.
1173
+
1174
+
1133
1175
  ### Set and Clear value for Collect Elements (DEV ENV ONLY)
1134
1176
 
1135
1177
  `setValue(value: string)` method is used to set the value of the element. This method will override any previous value present in the element.
@@ -2367,6 +2409,31 @@ cardNumber.setError('custom error');
2367
2409
  // Reset custom error.
2368
2410
  cardNumber.resetError();
2369
2411
  ```
2412
+
2413
+ ### Override default error messages
2414
+
2415
+ You can override the default error messages with custom ones by using `setErrorOverride`. This is especially useful to override default error messages in non-English languages.
2416
+
2417
+ ```javascript
2418
+ const container = skyflowClient.container(Skyflow.ContainerType.REVEAL);
2419
+
2420
+ const cardNumber = container.create({
2421
+ token: '89024714-6a26-4256-b9d4-55ad69aa4047',
2422
+ });
2423
+
2424
+ const revealButton = document.getElementById('revealPCIData');
2425
+
2426
+ if (revealButton) {
2427
+ revealButton.addEventListener('click', () => {
2428
+ revealContainer.reveal().then((res) => {
2429
+ //handle reveal response
2430
+ }).catch((err) => {
2431
+ cardNumber.setErrorOverride("custom error")
2432
+ });
2433
+ });
2434
+ }
2435
+ ```
2436
+
2370
2437
  ### Set token for Reveal Elements
2371
2438
 
2372
2439
  The `setToken(value: string)` method can be used to set the token of the Reveal Element. If no altText is set, the set token will be displayed on the UI as well. If altText is set, then there will be no change in the UI but the token of the element will be internally updated.