@globalbrain/sefirot 3.35.3 → 3.36.0
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.
|
@@ -19,6 +19,7 @@ export { requiredHms } from './requiredHms'
|
|
|
19
19
|
export { requiredIf } from './requiredIf'
|
|
20
20
|
export { requiredYmd } from './requiredYmd'
|
|
21
21
|
export { rule } from './rule'
|
|
22
|
+
export { slackChannelName } from './slackChannelName'
|
|
22
23
|
export { url } from './url'
|
|
23
24
|
export { ymd } from './ymd'
|
|
24
25
|
export { zeroOrNegativeInteger } from './zeroOrNegativeInteger'
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createRule } from '../Rule'
|
|
2
|
+
import { type SlackChannelNameOptions, slackChannelName as baseSlackChannelName } from '../validators'
|
|
3
|
+
|
|
4
|
+
export const message = {
|
|
5
|
+
en: 'The slack channel name is invalid.',
|
|
6
|
+
ja: 'Slackチャンネル名の形式が正しくありません。'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function slackChannelName(options?: SlackChannelNameOptions, msg?: string) {
|
|
10
|
+
return createRule({
|
|
11
|
+
message: ({ lang }) => msg ?? message[lang],
|
|
12
|
+
optional: true,
|
|
13
|
+
validation: (value) => baseSlackChannelName(value, options)
|
|
14
|
+
})
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isString } from '../../support/Utils'
|
|
2
|
+
|
|
3
|
+
export interface SlackChannelNameOptions {
|
|
4
|
+
offset?: number
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function slackChannelName(value: unknown, options: SlackChannelNameOptions = {}): boolean {
|
|
8
|
+
if (!isString(value)) {
|
|
9
|
+
return false
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const { offset = 0 } = options
|
|
13
|
+
const maxLength = /* Slack channel name max length */ 80 - offset
|
|
14
|
+
|
|
15
|
+
return new RegExp(`^[\\p{L}\\p{M}\\p{N}_-]{1,${maxLength}}$`, 'u').test(value)
|
|
16
|
+
}
|