Getting Started
Installation
Requirements and setup instructions for the Zema package in Dart and Flutter projects.
Requirements
- Dart SDK 3.5.0 or higher.
Add the Dependency
dependencies:
zema: ^1.0.0
Install:
# Dart
dart pub get
# Flutter
flutter pub get
Verify the Installation
import 'package:zema/zema.dart';
void main() {
final schema = z.object({
'name': z.string().min(2),
'age': z.integer().gte(0),
});
final result = schema.safeParse({
'name': 'Alice',
'age': 30,
});
if (result.isSuccess) {
print('Installation verified. Value: ${result.value}');
}
}
dart run verify_zema.dart
# Installation verified. Value: {name: Alice, age: 30}
Import
All public types are available from a single import:
import 'package:zema/zema.dart';
This exposes:
zandzema: the schema factory singleton.ZemaSchema,ZemaResult,ZemaSuccess,ZemaFailure: core types.ZemaIssue,ZemaException: error types.ZemaErrorMap,ZemaI18n: error customisation and localisation.