Required Fields¶
Required Fields
is a Schema Constraint that checks if a field is required, and confirms that required fields are defined.
Usage Example¶
fields:
- name: name
type: string
description: |
The name of the type.
is_required: true
- name: package
type: string
description: |
The 'dot notation' package name for the type. All type names must be unique within an assigned type.
The package will also define the directory structure produced by gen-plugin.
is_required: true
- name: description
type: string
description: |
A brief description of the type.
is_required: true
In the above example, the fields name
and package
are required, and the field description
is not required. If name
or package
are not defined, it will fail the Required Fields
constraint.
This constraint does not check required fields of parent definitions
schema:
name: AacType
package: aac.lang
modifiers:
- abstract
description: |
The base type for any data item defined in AaC.
fields:
- name: name
type: string
description: |
The name of the type.
is_required: true
- name: package
type: string
description: |
The 'dot notation' package name for the type. All type names must be unique within an assigned type.
The package will also define the directory structure produced by gen-plugin.
is_required: true
- name: description
type: string
description: |
A brief description of the type.
is_required: true
schema:
name: Schema
extends:
- package: aac.lang
name: AacType
package: aac.lang
root: schema
description: |
A definition that defines the schema/structure of data.
fields:
- name: extends
type: SchemaExtension[]
description: |
A list of Schema definition names that this definition inherits from.
- name: modifiers
type: dataref(modifier.name)[]
description:
A means of further defining the schema and how it can be used within the model.
- name: root
type: string
description: |
The root key to use when declaring an instance of the type in yaml/aac files.
- name: fields
type: Field[]
description: |
A list of fields that make up the definition.
is_required: true
- name: requirements
type: dataref(req.id)[]
description: |
A list of requirements associated with this schema.
- name: constraints
type: SchemaConstraintAssignment[]
In the above example, Schema
is an extension of AaCType
. So while a Schema
definition can use the name
, description
, and package
fields from AaCType
, the is_required
field does not carry over. If you want an extension’s field to be required, you will have to redefine the field.