Creating a Schema
Schema
?
Why use a Schemas are the key to providing predictable data, autocomplete and type-checking in your ActiveClasses.

Schema
Writing a basic Let's say that we want to model a user. Here's how we might do it.
- JavaScript
- TypeScript
import { Schema } from 'fireactive'
const userSchema = {
name: Schema.string, // users must have a name
age: Schema.number({ optional: true }), // age is optional
role: Schema.enum(['admin', 'basic']), // role must be 'admin' or 'basic'
isVerified: Schema.boolean({ default: false }) // defaults to false
}
Schema
fields are all required, unless explicitly passed either { optional: true }
or { required: false }
as options.
Now you've written a Schema
, you're ready to create your first Fireactive ActiveClass
!