-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from axhxrx/1-cannot-publish-due-to-jsr-compati…
…bility-issues 1 cannot publish due to jsr compatibility issues
- Loading branch information
Showing
9 changed files
with
48 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
import { ValidatedString } from './ValidatedString.ts'; | ||
|
||
const isAlphabeticOrUnderscoreOrHyphen = (s: string) => /^[a-zA-Z_-]+$/.test(s); | ||
|
||
const { factory, type } = ValidatedString.create(isAlphabeticOrUnderscoreOrHyphen, { | ||
name: 'AlphabeticOrUnderscoreOrHyphenString', | ||
description: 'must contain only letters (A-Z, a-z), underscores, or hyphens', | ||
}); | ||
// Why JSRCompatibleFactory? See https://github.com/axhxrx/validated-string/issues/1 | ||
const JSRCompatibleFactory = ValidatedString.create( | ||
isAlphabeticOrUnderscoreOrHyphen, | ||
{ | ||
name: 'AlphabeticOrUnderscoreOrHyphenString', | ||
description: 'must contain only letters (A-Z, a-z), underscores, or hyphens', | ||
}, | ||
); | ||
|
||
const type = JSRCompatibleFactory.type; | ||
const factory = JSRCompatibleFactory.factory; | ||
|
||
export type AlphabeticOrUnderscoreOrHyphenString = typeof type; | ||
export const AlphabeticOrUnderscoreOrHyphenString = factory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { ValidatedString } from './ValidatedString.ts'; | ||
|
||
const isAlphabeticOrUnderscore = (s: string) => /^[a-zA-Z_]+$/.test(s); | ||
const isAlphabeticOrUnderscore = (s: string): boolean => /^[a-zA-Z_]+$/.test(s); | ||
|
||
const { factory, type } = ValidatedString.create(isAlphabeticOrUnderscore, { | ||
const JSRCompatibleFactory = ValidatedString.create(isAlphabeticOrUnderscore, { | ||
name: 'AlphabeticOrUnderscoreString', | ||
description: 'must contain only letters (A-Z, a-z) or underscores', | ||
}); | ||
|
||
export type AlphabeticOrUnderscoreString = typeof type; | ||
export const AlphabeticOrUnderscoreString = factory; | ||
export type AlphabeticOrUnderscoreString = typeof JSRCompatibleFactory.type; | ||
export const AlphabeticOrUnderscoreString = JSRCompatibleFactory.factory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { ValidatedString } from './ValidatedString.ts'; | ||
|
||
const isAlphabetic = (s: string) => /^[a-zA-Z]+$/.test(s); | ||
const isAlphabetic = (s: string): boolean => /^[a-zA-Z]+$/.test(s); | ||
|
||
const { factory, type } = ValidatedString.create(isAlphabetic, { | ||
const JSRCompatibleFactory = ValidatedString.create(isAlphabetic, { | ||
name: 'AlphabeticString', | ||
description: 'must contain only letters (A-Z, a-z)', | ||
}); | ||
|
||
export type AlphabeticString = typeof type; | ||
export const AlphabeticString = factory; | ||
export type AlphabeticString = typeof JSRCompatibleFactory.type; | ||
export const AlphabeticString = JSRCompatibleFactory.factory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { ValidatedString } from './ValidatedString.ts'; | ||
|
||
const isLowercaseAlpha = (s: string) => /^[a-z]+$/.test(s); | ||
const isLowercaseAlpha = (s: string): boolean => /^[a-z]+$/.test(s); | ||
|
||
const { factory, type } = ValidatedString.create(isLowercaseAlpha, { | ||
const JSRCompatibleFactory = ValidatedString.create(isLowercaseAlpha, { | ||
name: 'LowercaseAlphabeticString', | ||
description: 'must contain only lowercase letters a-z', | ||
description: 'must contain only lowercase letters (a-z)', | ||
}); | ||
|
||
export type LowercaseAlphabeticString = typeof type; | ||
export const LowercaseAlphabeticString = factory; | ||
export type LowercaseAlphabeticString = typeof JSRCompatibleFactory.type; | ||
export const LowercaseAlphabeticString = JSRCompatibleFactory.factory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { ValidatedString } from './ValidatedString.ts'; | ||
|
||
const isPrometheusMetricName = (s: string) => /^[a-zA-Z_:][a-zA-Z0-9_:]*$/.test(s); | ||
const isPrometheusMetricName = (s: string): boolean => /^[a-zA-Z_:][a-zA-Z0-9_:]*$/.test(s); | ||
|
||
const { factory, type } = ValidatedString.create(isPrometheusMetricName, { | ||
const JSRCompatibleFactory = ValidatedString.create(isPrometheusMetricName, { | ||
name: 'PrometheusMetricName', | ||
description: 'must start with a letter, underscore, or colon, followed by letters, digits, underscores, or colons', | ||
}); | ||
|
||
/** | ||
A validated string that represents a Prometheus metric name. See {@link ValidatedString} for more information. Note that this might not really exactly match the rules for Prometheus metric names, but it's close enough for our purposes; namely, generating metrics — don't rely on this to *validate* Prometheus metric names, as it is based on a quick skim of the Prometheus docs. | ||
*/ | ||
export type PrometheusMetricName = typeof type; | ||
export const PrometheusMetricName = factory; | ||
export type PrometheusMetricName = typeof JSRCompatibleFactory.type; | ||
export const PrometheusMetricName = JSRCompatibleFactory.factory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { ValidatedString } from './ValidatedString.ts'; | ||
|
||
const isPrometheusMetricNameWithoutColon = (s: string) => /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s); | ||
const isPrometheusMetricNameWithoutColon = (s: string): boolean => /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s); | ||
|
||
const { factory, type } = ValidatedString.create(isPrometheusMetricNameWithoutColon, { | ||
name: 'PrometheusMetricNameWithoutColon', | ||
description: 'must start with a letter or underscore, followed by letters, digits, or underscores', | ||
}); | ||
const JSRCompatibleFactory = ValidatedString.create( | ||
isPrometheusMetricNameWithoutColon, | ||
{ | ||
name: 'PrometheusMetricNameWithoutColon', | ||
description: 'must start with a letter or underscore, followed by letters, digits, or underscores', | ||
}, | ||
); | ||
|
||
export type PrometheusMetricNameWithoutColon = typeof type; | ||
export const PrometheusMetricNameWithoutColon = factory; | ||
export type PrometheusMetricNameWithoutColon = typeof JSRCompatibleFactory.type; | ||
export const PrometheusMetricNameWithoutColon = JSRCompatibleFactory.factory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters