summaryrefslogtreecommitdiff
path: root/node_modules/schema-utils/dist/util/hints.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-11-05 17:23:37 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-11-05 17:23:37 +0800
commit2cdf0cb352ab6a2d0f8cb25120e4ebc92c5316e3 (patch)
tree6b088c99810bd013f17b80522c936ca6dfc09858 /node_modules/schema-utils/dist/util/hints.js
parentf8ee6ef722e6c560c4a1c879e04dbdf0b01f0316 (diff)
removed autoprefix hover as it will have a high chance of making hover stopped working
Diffstat (limited to 'node_modules/schema-utils/dist/util/hints.js')
-rw-r--r--node_modules/schema-utils/dist/util/hints.js105
1 files changed, 0 insertions, 105 deletions
diff --git a/node_modules/schema-utils/dist/util/hints.js b/node_modules/schema-utils/dist/util/hints.js
deleted file mode 100644
index 4317b86f..00000000
--- a/node_modules/schema-utils/dist/util/hints.js
+++ /dev/null
@@ -1,105 +0,0 @@
-"use strict";
-
-const Range = require("./Range");
-/** @typedef {import("../validate").Schema} Schema */
-
-/**
- * @param {Schema} schema
- * @param {boolean} logic
- * @return {string[]}
- */
-
-
-module.exports.stringHints = function stringHints(schema, logic) {
- const hints = [];
- let type = "string";
- const currentSchema = { ...schema
- };
-
- if (!logic) {
- const tmpLength = currentSchema.minLength;
- const tmpFormat = currentSchema.formatMinimum;
- const tmpExclusive = currentSchema.formatExclusiveMaximum;
- currentSchema.minLength = currentSchema.maxLength;
- currentSchema.maxLength = tmpLength;
- currentSchema.formatMinimum = currentSchema.formatMaximum;
- currentSchema.formatMaximum = tmpFormat;
- currentSchema.formatExclusiveMaximum = !currentSchema.formatExclusiveMinimum;
- currentSchema.formatExclusiveMinimum = !tmpExclusive;
- }
-
- if (typeof currentSchema.minLength === "number") {
- if (currentSchema.minLength === 1) {
- type = "non-empty string";
- } else {
- const length = Math.max(currentSchema.minLength - 1, 0);
- hints.push(`should be longer than ${length} character${length > 1 ? "s" : ""}`);
- }
- }
-
- if (typeof currentSchema.maxLength === "number") {
- if (currentSchema.maxLength === 0) {
- type = "empty string";
- } else {
- const length = currentSchema.maxLength + 1;
- hints.push(`should be shorter than ${length} character${length > 1 ? "s" : ""}`);
- }
- }
-
- if (currentSchema.pattern) {
- hints.push(`should${logic ? "" : " not"} match pattern ${JSON.stringify(currentSchema.pattern)}`);
- }
-
- if (currentSchema.format) {
- hints.push(`should${logic ? "" : " not"} match format ${JSON.stringify(currentSchema.format)}`);
- }
-
- if (currentSchema.formatMinimum) {
- hints.push(`should be ${currentSchema.formatExclusiveMinimum ? ">" : ">="} ${JSON.stringify(currentSchema.formatMinimum)}`);
- }
-
- if (currentSchema.formatMaximum) {
- hints.push(`should be ${currentSchema.formatExclusiveMaximum ? "<" : "<="} ${JSON.stringify(currentSchema.formatMaximum)}`);
- }
-
- return [type].concat(hints);
-};
-/**
- * @param {Schema} schema
- * @param {boolean} logic
- * @return {string[]}
- */
-
-
-module.exports.numberHints = function numberHints(schema, logic) {
- const hints = [schema.type === "integer" ? "integer" : "number"];
- const range = new Range();
-
- if (typeof schema.minimum === "number") {
- range.left(schema.minimum);
- }
-
- if (typeof schema.exclusiveMinimum === "number") {
- range.left(schema.exclusiveMinimum, true);
- }
-
- if (typeof schema.maximum === "number") {
- range.right(schema.maximum);
- }
-
- if (typeof schema.exclusiveMaximum === "number") {
- range.right(schema.exclusiveMaximum, true);
- }
-
- const rangeFormat = range.format(logic);
-
- if (rangeFormat) {
- hints.push(rangeFormat);
- }
-
- if (typeof schema.multipleOf === "number") {
- hints.push(`should${logic ? "" : " not"} be multiple of ${schema.multipleOf}`);
- }
-
- return hints;
-}; \ No newline at end of file