Closed bwgjoseph closed 3 years ago
I am not aware of something like this, but what would be the use case ?
I could say, write a plugin that only runs if a certain field exists.
if (Object.keys(schema.paths).includes('certainfield')) {
// do some manipulation to the data
}
or just purely check if certain fields exists
function doesFieldExist(schema, fieldName) {
return Object.keys(schema.paths).includes(fieldName);
}
I am currently using this checks to perform certain action across different schemas based on what fields exists or not exists.
from Lino
function doesFieldExist(schema: Schema, fieldName: string): boolean {
return !!schema.path(fieldName)
}
Thank you for the suggestion, it works as expected
Hi,
Is there any way to grab the list of fields that is registered for a given schema?
I saw on the docs that
ottoman
haspath
but notpaths
method.