required property

List<String>? get required

A list of the required properties by name.

For example, to define a schema for an object that requires a name property:

final schema = ObjectSchema(
  required: ['name'],
  properties: {'name': Schema.string()},
);

In this schema, an object like {'name': 'John'} would be valid, but {} or {'age': 30} would be invalid because they do not contain the required name property. Note that the type of the name property is also defined using the properties field; required only enforces the presence of the property, not its type or value, which are handled by the corresponding schema in the properties map (if provided, otherwise any value is accepted).

Properties in this list must be set in the object.

Implementation

List<String>? get required => (_value['required'] as List?)?.cast<String>();