You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Although in a validation context, default doesn't really serve any purpose, in a generation context, it can be quite useful. The above as a JSON Schema could be written as:
(While validating that the default value meets the requirements of the schema that contains it isn't possible with meta-schema validation, I think a linter could probably pick it up.)
One caveat to this is that languages that do support this typically require that the initialization values are compile-time constants, so generally they're limited to strings, booleans, numbers, etc (no complex objects). There are generally other mechanisms for initializing more complex values.
The text was updated successfully, but these errors were encountered:
Many languages allow for an initial value to be set for a property upon instantiation. For example, in C# we do this:
Although in a validation context,
default
doesn't really serve any purpose, in a generation context, it can be quite useful. The above as a JSON Schema could be written as:(While validating that the
default
value meets the requirements of the schema that contains it isn't possible with meta-schema validation, I think a linter could probably pick it up.)One caveat to this is that languages that do support this typically require that the initialization values are compile-time constants, so generally they're limited to strings, booleans, numbers, etc (no complex objects). There are generally other mechanisms for initializing more complex values.
The text was updated successfully, but these errors were encountered: