Expand description
Validation for POST /schemas/:className and PUT /schemas/:className.
Pure. No I/O, no routing, no schema cache. A create returns the ClassSchema the caller
should persist; an update returns a SchemaMutation the caller executes. Upstream fuses
validation with execution across addClassIfNotExists (SchemaController.js:832-868) and
updateClass (:870-975), which is why an upstream field delete can half-happen. Splitting
them here does not make the sequence atomic, and it does make the decision reviewable in one
place.
0.2.0 scope: field options are stored, not enforced. required and defaultValue are
validated against the field’s type and round-tripped exactly as sent: a schema body is
decoded without interpreting any __type envelope, so an offset instant, unpadded base64 and
any key the envelope does not declare all survive. Stored into
ClassSchema::field_options, which the Mongo adapter writes to _metadata.fields_options.
Nothing consults them on a write. That is a deliberate exclusion, and storing them anyway is
what keeps a mixed fleet honest: a parse-server node reading the same database enforces them,
and dropping the keys on a parse-rust rewrite would silently relax a constraint it never
agreed to relax.
Two error codes upstream uses here are bare numbers with no name in the parse SDK’s table.
They have ErrorCode variants all the same, named from their messages, because the number is
what a client sees. See NEEDS_CLASS_NAME_CODE.
Structs§
- Schema
Mutation - A
PUT /schemas/:classNamereduced to the work the caller has to do. - SetField
- One submitted field spec, split into the parts that are stored in two different places.
Enums§
- Field
Change - What a
fieldsentry in a schema-API body asks for.
Constants§
- FIELD_
CANNOT_ BE_ ADDED_ CODE 136,field <name> cannot be added(SchemaController.js:1038-1039,:1242). SeeNEEDS_CLASS_NAME_CODEfor why this is a named constant.- NEEDS_
CLASS_ NAME_ CODE 135,type <T> needs a class name(SchemaController.js:508,SchemasRouter.js:90).
Functions§
- check_
default_ value_ type - The
defaultValuetype check asenforceFieldExistsruns it (SchemaController.js:1145-1162), which is the only option validation an already-existing field gets. - parse_
field_ type fieldTypeIsInvalid(SchemaController.js:505-524), inverted into a parse.- parse_
fields - Decode a
fieldsobject into per-field changes. - plan_
update - Validate a
PUT /schemas/:classNamebody against the stored schema and produce the plan. - validate_
new_ class - Validate a
POST /schemas/:classNamebody and produce the schema to create.