FieldValueWrite.h header

#include <ew/app/FieldValueWrite.h>

Namespace ew::app

Functions

std::optional< ew::core::entity::FieldValue > ew::app::entity::coerceForField(const ew::core::project::Project &project, const ew::core::entity::Entity &entity, QStringView key, const QString &text, ew::core::entity::FieldValueCoercionError *error=nullptr)

text as a value of whatever type entity's field key is declared as, or std::nullopt with error filled in when it will not convert.

The write boundary. Entity itself cannot do this: it holds values, not the schema, and the fields that apply to it come from its category chain AND from the properties it holds itself. So every surface that writes a value from text – the inspector, an MCP tool, a script, a spreadsheet import – comes through here, parses once, and is told plainly when the text is not what the field says it is.

A key the entity's schema does not mention is treated as Text. Ad-hoc keys are legitimate (a value can outlive the definition that named it, which is exactly why the property migration reports rather than deletes), and refusing to store one would lose data to protect a schema that does not claim it.