Types Provider
Similar to the Expression Plugin, this plugin adds support for easily exposing new DataTypes
, formats
, and validations
to Player’s content.
Example
Define a new validation type:
Create a new DataType
that references it:
Register it with Player:
Given a data-type reference to CustomType
in the content, your new validation will be used:
The swift TypesProviderPlugin
enables adding custom data types, formatters and validation purely through swift code. While in general, the recommendation would be to share a single JavaScript implementation to multiple platforms, some use cases may need a native integration.
CocoaPods
Add the subspec to your Podfile
Swift Usage
Custom Validator
then in the JSON schema for your type:”
Custom Formatter
then in the JSON schema for your type:
Formatting Options
The second parameter passed to the format/deformat functions is for additional options, it is of type [String: Any]
and contains any other keys that were passed alongside the type
of the formatter:
Custom Types
Just as you can define custom formats and validation, you can define a custom type that encapsulates that functionality into a type, to avoid the need to keep specifying options, this is how the common-types are defined, so when you choose a type like DateType
the formatting is already set up.
then in your JSON schema:
Options in the CustomType
You can supply options to formatters of your custom type in the ValidationReference
or FormatReference
: