Behaviour SwRS-MDOKFSTUDIO-FMEDIT-016
The host refuses a value that breaks YAML, the field type or the schema, and ignores a malformed save message
When the host receives a frontmatter save whose YAML value does not parse or is empty, or whose value does not fit the field type or the schema, the extension SHALL refuse it with "Invalid YAML value: {parser message}" for a YAML value and with the matching message otherwise, and change nothing; a previewFrontmatterSave message that does not name a non-empty editId and fieldName, or that carries a field outside its accepted shape, is ignored without a reply.
Scenarios 11
The situations the tests check; open one to read it.
nominalA YAML value that does not parse is refused
Givena save with fieldValueFormat yaml and the text [
Whenthe host plans the save
Thenthe answer is the error "Invalid YAML value: " followed by the parser message and the document is unchanged
refusalAn empty or non-text YAML value
| Save with fieldValueFormat yaml | Answer |
|---|
| an empty or blank text | "Invalid YAML value: Enter a YAML value." |
| a non-text payload | "The YAML field value must be text." |
A save with the flush flag skips the parse refusal and keeps the typed text (see SwRS-MDOKFSTUDIO-FMEDIT-067).
refusalA value that does not fit the field type
| Save received for a schema field | Answer (the document is unchanged) |
|---|
| null for a field that is not nullable | "The frontmatter field is stale or its value does not match the schema." |
| paused for an enum field with the values draft and active | the same stale-field message |
| a text, date or time that is not a string; a boolean field that is not a boolean; a number that is not finite; a list that is not an array | the same stale-field message |
boundaryValues that are accepted
| Save | Outcome |
|---|
| null for a nullable schema field | accepted |
| any value for a document without a schema | no type check applies and the value is written |
refusalA schema error on the edited field
| Save received | Answer (the document is unchanged) |
|---|
| a value that violates a constraint of the schema field | "Schema validation failed: " followed by the schema message |
| null for a nullable field that a conditional (if/then) rule requires to be set | "Schema validation failed: " followed by the schema message |
| a rename after which the field cannot be found in the re-analysis | "The renamed frontmatter field could not be validated." |
| null for a field whose conditional (if/then) rule does not apply because the condition is not met | not refused: the same null save is accepted and written |
boundaryOnly errors of the edited field block a save
| Situation | Outcome |
|---|
| the only error of the edited field is a broken link | the save is accepted |
| another field of the frontmatter has a schema error and a different field is edited with a valid value | the save is accepted |
refusalA save for a missing field or revision is stale
| Save received | Answer (the document is unchanged) |
|---|
| a field name absent from the current analysis | "The frontmatter field is stale or its value does not match the schema." |
| a document revision that differs from the revision of the document | the same stale-field message |
| an add of a name that already exists | the same stale-field message |
nominalA frontmatter save that names its editor and field is accepted
| previewFrontmatterSave message | Outcome |
|---|
| editId e1 and fieldName status (with its fieldValue) | accepted |
| frontmatterAction add, afterField status and newFieldName owner | accepted |
The envelope, the size bound and the pin fields (pinLine, pinViewportTop) are checked once for all page messages (see SwRS-MDOKFSTUDIO-TRUST-052).
refusalA save that does not name its editor, field or value is ignored
| previewFrontmatterSave message | Outcome |
|---|
| without fieldName, or with an empty fieldName | refused: nothing is replied and the document is unchanged |
| without editId, or with an empty editId | refused: nothing is replied and the document is unchanged |
| without fieldValue, unless frontmatterAction is remove | refused: nothing is replied and the document is unchanged |
| with fieldValueFormat other than yaml | refused: nothing is replied and the document is unchanged |
boundaryAccepted bounds of the optional fields
| Field | Accepted shape |
|---|
| afterField | a string of 1 to 1024 characters without a line break, only with frontmatterAction add; an add whose afterField contains a line break, or a remove with afterField, is dropped and the document is unchanged |
| frontmatterAction | add or remove |
| fieldValueFormat | yaml |
| fieldValueStyle | plain, and only with no frontmatterAction and no fieldValueFormat |
| flush | true |
| newFieldName | a string |
refusalThe frontmatter-save fields are accepted only on a frontmatter save
Givena previewScroll message with newFieldName owner (or any other message type that carries fieldValueFormat, fieldValueStyle, newFieldName, afterField or frontmatterAction)
Whenit is checked
Thenit is refused
Known limits (1)
- the stale-field message is shared by a stale render, a missing field, an add of an existing name and a type mismatch; the user cannot tell them apart.