Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/player/src/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ export interface ExtendedPlayerPlugin<
Expressions = void,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
DataTypes = void,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Formatters = void,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Validators = void,
> {}

export interface PlayerConfigOptions {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"@docsearch/react": "3",
"@eslint/js": "^9.22.0",
"@monaco-editor/react": "^4.6.0",
"@player-tools/cli": "0.12.0",
"@player-tools/dsl": "0.12.0",
"@player-tools/xlr": "0.12.0",
"@player-tools/cli": "0.13.0--canary.242.6147",
"@player-tools/dsl": "0.13.0--canary.242.6147",
"@player-tools/xlr": "0.13.0--canary.242.6147",
"@player-tools/xlr-utils": "0.6.1-next.2",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-separator": "^1.0.3",
Expand Down
4 changes: 2 additions & 2 deletions plugins/common-types/core/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@rules_player//javascript:defs.bzl", "js_pipeline")
load("@rules_player//player:defs.bzl", "js_xlr_pipeline")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("//tools:defs.bzl", "NATIVE_BUILD_DEPS", "tsup_config", "vitest_config")

Expand All @@ -8,7 +8,7 @@ tsup_config(name = "tsup_config")

vitest_config(name = "vitest_config")

js_pipeline(
js_xlr_pipeline(
package_name = "@player-ui/common-types-plugin",
build_deps = NATIVE_BUILD_DEPS,
native_bundle = "CommonTypesPlugin",
Expand Down
46 changes: 44 additions & 2 deletions plugins/common-types/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TypesProviderPlugin } from "@player-ui/types-provider-plugin";
import * as validators from "./validators";
import * as dataTypes from "./data-types/types";
import * as formats from "./formats";
import type {
import {
BooleanType,
IntegerType,
IntegerPosType,
Expand All @@ -15,6 +15,25 @@ import type {
PhoneType,
} from "./data-types/types";

import { commaNumber, currency, date, integer, phone } from "./formats/index";

import {
collection,
email,
expression,
integer as vinteger,
length,
max,
min,
oneOf,
phone as vphone,
readonly,
regex,
required,
string,
zip,
} from "./validators/index";

export { validators, dataTypes, formats };

export * from "./formats/utils";
Expand All @@ -37,12 +56,35 @@ export class CommonTypesPlugin
typeof CollectionType,
typeof DateType,
typeof PhoneType,
],
[
typeof commaNumber,
typeof currency,
typeof date,
typeof integer,
typeof phone,
],
[
typeof collection,
typeof email,
typeof expression,
typeof vinteger,
typeof length,
typeof max,
typeof min,
typeof oneOf,
typeof vphone,
typeof readonly,
typeof regex,
typeof required,
typeof string,
typeof zip,
]
>
{
name = "CommonTypes";

apply(player: Player) {
apply(player: Player): void {
player.registerPlugin(
new TypesProviderPlugin({
types: Object.values(dataTypes),
Expand Down
6 changes: 3 additions & 3 deletions plugins/common-types/core/src/validators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,21 +347,21 @@ const stringRegexValidator = (
};

/** Checks that the given value represents an email */
export const email = stringRegexValidator(
export const email: ValidatorFunction = stringRegexValidator(
EMAIL_REGEX,
"validation.email",
"Improper email format",
);

/** Checks that the given value represents a phone number */
export const phone = stringRegexValidator(
export const phone: ValidatorFunction = stringRegexValidator(
PHONE_REGEX,
"validation.phone",
"Invalid phone number",
);

/** Checks that the given value represents a phone number */
export const zip = stringRegexValidator(
export const zip: ValidatorFunction = stringRegexValidator(
ZIP_REGEX,
"validation.regex",
"Invalid zip code",
Expand Down
84 changes: 42 additions & 42 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.