dash-platform-sdk 1.3.0-dev.2 → 1.3.0-dev.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dash-platform-sdk",
3
- "version": "1.3.0-dev.2",
3
+ "version": "1.3.0-dev.3",
4
4
  "main": "index.js",
5
5
  "description": "Lightweight SDK for accessing Dash Platform blockchain",
6
6
  "ts-standard": {
@@ -57,4 +57,12 @@ export declare class NamesController {
57
57
  * @return {string}
58
58
  */
59
59
  normalizeLabel(label: string): string;
60
+ /**
61
+ * Validates a DPNS name that you would like to register
62
+ *
63
+ * @param fullName {string} full DPNS name (ex. pshenmic.dash)
64
+ *
65
+ * @return {string} null if valid or string with a reason
66
+ */
67
+ validateName(fullName: string): null | string;
60
68
  }
@@ -155,6 +155,16 @@ var NamesController = /** @class */ (function () {
155
155
  NamesController.prototype.normalizeLabel = function (label) {
156
156
  return (0, convertToHomographSafeChars_1.default)(label);
157
157
  };
158
+ /**
159
+ * Validates a DPNS name that you would like to register
160
+ *
161
+ * @param fullName {string} full DPNS name (ex. pshenmic.dash)
162
+ *
163
+ * @return {string} null if valid or string with a reason
164
+ */
165
+ NamesController.prototype.validateName = function (fullName) {
166
+ return (0, validateName_1.default)(fullName);
167
+ };
158
168
  return NamesController;
159
169
  }());
160
170
  exports.NamesController = NamesController;
@@ -6,9 +6,9 @@ function validateName(fullName) {
6
6
  if (chunks.length !== 2) {
7
7
  return 'Name to search should be a full domain name (ex. pshenmic.dash)';
8
8
  }
9
- var parentDomainName = chunks[1];
9
+ var label = chunks[0], parentDomainName = chunks[1];
10
10
  if (parentDomainName !== 'dash') {
11
11
  return 'Root domain must be .dash';
12
12
  }
13
- return null;
13
+ return /^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]$/.test(label) ? null : 'Unacceptable label name';
14
14
  }