This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Account implements AggregateModel { | |
String id; | |
String owner; | |
double amount; | |
Account({this.id = Uuid().v4(), this.owner, this.amount}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2025 Fredrick Allan Grott. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
// | |
// Modified from jaguar cqrs MIT license | |
// Copyright 2016 | |
import 'dart:async'; | |
import 'package:fdd_api/core/cqrs/definition.dart'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2025 Fredrick Allan Grott. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
// | |
// Modified from jaguar cqrs MIT license | |
// Copyright 2016 | |
// ignore_for_file: use_setters_to_change_properties | |
import 'dart:async'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() async { | |
final cqrs = CQRS() | |
..registerAggregate(AccountAggregate()) | |
..resigerRepository(InMemoryRepository<Account>(forAggregate: "account")); | |
cqrs.events.listen(debugPrint); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2025 Fredrick Allan Grott. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
// | |
// Modified from jaguar cqrs MIT license | |
// Copyright 2016 | |
// ignore_for_file: unnecessary_null_comparison | |
import 'dart:async'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2025 Fredrick Allan Grott. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
// ignore_for_file: unnecessary_null_comparison | |
import 'package:dartz/dartz.dart'; | |
import 'package:fdd_api/core/value_objects/errors.dart'; | |
import 'package:fdd_api/core/value_objects/failures.dart'; | |
import 'package:fdd_api/core/value_objects/ivalidatable.dart'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2025 Fredrick Allan Grott. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
import 'package:dartz/dartz.dart'; | |
import 'package:fdd_api/core/value_objects/failures.dart'; | |
import 'package:kt_dart/kt.dart'; | |
Either<ValueFailure<String>, String> validateMaxStringLength(String input, int maxLength) { | |
if (input.length <= maxLength) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2025 Fredrick Allan Grott. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
abstract class IValidatable { | |
bool isValid(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2025 Fredrick Allan Grott. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
import 'package:freezed_annotation/freezed_annotation.dart'; | |
part 'failures.freezed.dart'; | |
@freezed | |
abstract class ValueFailure<T> with _$ValueFailure<T> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2025 Fredrick Allan Grott. All rights reserved. | |
// Use of this source code is governed by a BSD-style | |
// license that can be found in the LICENSE file. | |
import 'package:fdd_api/core/value_objects/failures.dart'; | |
class UnexpectedValueError extends Error { | |
final ValueFailure valueFailure; | |
UnexpectedValueError(this.valueFailure); |