export const toFieldSpec = (properties, rules) => {
    const { type, name, isPii, helpText } = properties;
    const { validationRules } = rules;
    const trimmedHelpText = helpText.trim();
    const hasRules = validationRules.required !== undefined ||
        validationRules.charactersLimit !== undefined;
    const validation = hasRules
        ? {
            required: Boolean(validationRules.required),
            ...(validationRules.charactersLimit !== undefined && {
                stringLengthRange: validationRules.charactersLimit,
            }),
        }
        : undefined;
    return {
        type,
        displayName: name.trim(),
        ...(isPii && { isPii: true }),
        ...(trimmedHelpText && { helpText: trimmedHelpText }),
        ...(validation && { validation }),
    };
};
//# sourceMappingURL=toFieldSpec.js.map