UNPKG

1.09 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.checkName = checkName;
4/**
5 * Checks that supplied field meets Apple HomeKit naming rules
6 * https://developer.apple.com/design/human-interface-guidelines/homekit#Help-people-choose-useful-names
7 * @private Private API
8 */
9function checkName(displayName, name, value) {
10 // Ensure the string starts and ends with a Unicode letter or number and allow any combination of letters, numbers, spaces, and apostrophes in the middle.
11 if (typeof value === "string" && !(new RegExp(/^[\p{L}\p{N}][\p{L}\p{N} ']*[\p{L}\p{N}]$/u)).test(value)) {
12 console.warn("HAP-NodeJS WARNING: The accessory '" + displayName + "' has an invalid '" + name + "' characteristic ('" + value + "'). Please use only " +
13 "alphanumeric, space, and apostrophe characters. Ensure it starts and ends with an alphabetic or numeric character, and avoid emojis. This may prevent " +
14 "the accessory from being added in the Home App or cause unresponsiveness.");
15 }
16}
17//# sourceMappingURL=checkName.js.map
\No newline at end of file