mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 16:25:21 +00:00
Renamed schema files and removed few TODOs
This commit is contained in:
@@ -1,75 +0,0 @@
|
||||
import Joi from "joi";
|
||||
import { Semantics } from "./SemanticTags";
|
||||
|
||||
/**
|
||||
* @see https://developer.apple.com/documentation/walletpasses/passfieldcontent
|
||||
* @TODO Rename interface to PassFieldContent to conform to above. This will be done in v3.0
|
||||
*/
|
||||
|
||||
export interface Field {
|
||||
attributedValue?: string | number | Date;
|
||||
changeMessage?: string;
|
||||
dataDetectorTypes?: string[];
|
||||
label?: string;
|
||||
textAlignment?: string;
|
||||
key: string;
|
||||
value: string | number | Date;
|
||||
semantics?: Semantics;
|
||||
dateStyle?: string;
|
||||
ignoresTimeZone?: boolean;
|
||||
isRelative?: boolean;
|
||||
timeStyle?: string;
|
||||
currencyCode?: string;
|
||||
numberStyle?: string;
|
||||
}
|
||||
|
||||
export const Field = Joi.object<Field>().keys({
|
||||
attributedValue: Joi.alternatives(
|
||||
Joi.string().allow(""),
|
||||
Joi.number(),
|
||||
Joi.date().iso(),
|
||||
),
|
||||
changeMessage: Joi.string(),
|
||||
dataDetectorTypes: Joi.array().items(
|
||||
Joi.string().regex(
|
||||
/(PKDataDetectorTypePhoneNumber|PKDataDetectorTypeLink|PKDataDetectorTypeAddress|PKDataDetectorTypeCalendarEvent)/,
|
||||
"dataDetectorType",
|
||||
),
|
||||
),
|
||||
label: Joi.string().allow(""),
|
||||
textAlignment: Joi.string().regex(
|
||||
/(PKTextAlignmentLeft|PKTextAlignmentCenter|PKTextAlignmentRight|PKTextAlignmentNatural)/,
|
||||
"graphic-alignment",
|
||||
),
|
||||
key: Joi.string().required(),
|
||||
value: Joi.alternatives(
|
||||
Joi.string().allow(""),
|
||||
Joi.number(),
|
||||
Joi.date().iso(),
|
||||
).required(),
|
||||
semantics: Semantics,
|
||||
// date fields formatters, all optionals
|
||||
dateStyle: Joi.string().regex(
|
||||
/(PKDateStyleNone|PKDateStyleShort|PKDateStyleMedium|PKDateStyleLong|PKDateStyleFull)/,
|
||||
"date style",
|
||||
),
|
||||
ignoresTimeZone: Joi.boolean(),
|
||||
isRelative: Joi.boolean(),
|
||||
timeStyle: Joi.string().regex(
|
||||
/(PKDateStyleNone|PKDateStyleShort|PKDateStyleMedium|PKDateStyleLong|PKDateStyleFull)/,
|
||||
"date style",
|
||||
),
|
||||
// number fields formatters, all optionals
|
||||
currencyCode: Joi.string().when("value", {
|
||||
is: Joi.number(),
|
||||
otherwise: Joi.string().forbidden(),
|
||||
}),
|
||||
numberStyle: Joi.string()
|
||||
.regex(
|
||||
/(PKNumberStyleDecimal|PKNumberStylePercent|PKNumberStyleScientific|PKNumberStyleSpellOut)/,
|
||||
)
|
||||
.when("value", {
|
||||
is: Joi.number(),
|
||||
otherwise: Joi.string().forbidden(),
|
||||
}),
|
||||
});
|
||||
Reference in New Issue
Block a user