File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { CHOICE_TOKEN } from '../choice-token'
12import { CHOICES_LIMIT } from '../choices-limit'
23import { isRecord } from '../is-record'
34import { refusal } from '../refusal'
4- import { TOKEN } from '../token'
55
66/**
77 * One property's value as it goes into the metadata: a finite number, a
@@ -49,7 +49,9 @@ export function checkedValue(
4949 const isTokenList =
5050 members . length > 0 &&
5151 members . length <= CHOICES_LIMIT &&
52- members . every ( member => typeof member === 'string' && TOKEN . test ( member ) )
52+ members . every (
53+ member => typeof member === 'string' && CHOICE_TOKEN . test ( member ) ,
54+ )
5355
5456 if ( ! isTokenList ) {
5557 throw refusal (
Original file line number Diff line number Diff line change 1+ /**
2+ * The shape of a Choice member: a snake_case token of at most 64 characters,
3+ * which may start with a digit (a bucket such as `110_to_143`), unlike a name
4+ * or a key (TOKEN).
5+ */
6+ export const CHOICE_TOKEN = / ^ [ a - z 0 - 9 ] [ a - z 0 - 9 _ ] { 0 , 63 } $ /
Original file line number Diff line number Diff line change 1+ export * from './choice-token.js'
2+
3+ export * as default from '.'
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ export * from './batch-of.js'
22export * from './checked-fields.js'
33export * from './checked-mark.js'
44export * from './checked-value'
5+ export * from './choice-token'
56export * from './choices-limit'
67export * from './core-event-prefix'
78export * from './event-prefix'
Original file line number Diff line number Diff line change 11/**
2- * The shape of an event name, a property key and a Choice member: a
3- * snake_case token of at most 64 characters, starting with a letter.
2+ * The shape of an event name and a property key: a snake_case token of at
3+ * most 64 characters, starting with a letter (a Choice member: CHOICE_TOKEN) .
44 */
55export const TOKEN = / ^ [ a - z ] [ a - z 0 - 9 _ ] { 0 , 63 } $ /
Original file line number Diff line number Diff line change 22 * A string property: the value and the list it is chosen from, declared
33 * beside it, so no free text reaches the row.
44 *
5- * Every member of `of` is a snake_case token, at most CHOICES_LIMIT of
6- * them; `value` is one of them.
5+ * Every member of `of` is a snake_case token, which may start with a digit,
6+ * at most CHOICES_LIMIT of them; `value` is one of them.
77 */
88export type Choice = { value : string ; of : readonly string [ ] }
You can’t perform that action at this time.
0 commit comments