Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Link to Field Tranforms on System/Fields is broken #12491

Closed
your-sudden-death opened this issue Mar 30, 2022 · 4 comments
Closed

Docs: Link to Field Tranforms on System/Fields is broken #12491

your-sudden-death opened this issue Mar 30, 2022 · 4 comments
Assignees

Comments

@your-sudden-death
Copy link
Contributor

your-sudden-death commented Mar 30, 2022

On the page https://docs.directus.io/reference/system/fields/
the link to field tranforms yields a 404. Does this doc page even exist?
image

@azrikahar
Copy link
Contributor

It does used to exist, just unfortunately got lost during the major docs rework in #9071. Linking the old file here so that we can lift it off from there later: https://github.com/directus/directus/blob/a257f324c0b2b2befae3ffe4df50ce2949412067/docs/reference/field-transforms.md

As there has been some changes to the naming of the transforms recently, in case you're wondering what are the latest ones, you can view them over here:

public transformers: Transformers = {
async hash({ action, value }) {
if (!value) return;
if (action === 'create' || action === 'update') {
return await generateHash(String(value));
}
return value;
},
async uuid({ action, value }) {
if (action === 'create' && !value) {
return uuidv4();
}
return value;
},
async 'cast-boolean'({ action, value }) {
if (action === 'read') {
if (value === true || value === 1 || value === '1') {
return true;
} else if (value === false || value === 0 || value === '0') {
return false;
} else if (value === null || value === '') {
return null;
}
}
return value;
},
async 'cast-json'({ action, value }) {
if (action === 'read') {
if (typeof value === 'string') {
try {
return JSON.parse(value);
} catch {
return value;
}
}
}
return value;
},
async conceal({ action, value }) {
if (action === 'read') return value ? '**********' : null;
return value;
},
async 'user-created'({ action, value, accountability }) {
if (action === 'create') return accountability?.user || null;
return value;
},
async 'user-updated'({ action, value, accountability }) {
if (action === 'update') return accountability?.user || null;
return value;
},
async 'role-created'({ action, value, accountability }) {
if (action === 'create') return accountability?.role || null;
return value;
},
async 'role-updated'({ action, value, accountability }) {
if (action === 'update') return accountability?.role || null;
return value;
},
async 'date-created'({ action, value }) {
if (action === 'create') return new Date();
return value;
},
async 'date-updated'({ action, value }) {
if (action === 'update') return new Date();
return value;
},
async 'cast-csv'({ action, value }) {
if (Array.isArray(value) === false && typeof value !== 'string') return;
if (action === 'read' && Array.isArray(value) === false) {
if (value === '') return [];
return value.split(',');
}
if (Array.isArray(value)) {
return value.join(',');
}
return value;
},
};

@rijkvanzanten
Copy link
Member

cc @erondpowell

@erondpowell erondpowell self-assigned this Apr 6, 2022
@erondpowell
Copy link
Contributor

cc @erondpowell

Noted

@rijkvanzanten
Copy link
Member

Fixed in 5cce44f. We're tracking the additional information in a different issue 👍🏻

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants