Skip to content

Commit

Permalink
fix!: Rename bool to boolean (#97)
Browse files Browse the repository at this point in the history
* refactor!(luthor): Rename bool to boolean

* fix(luthor_generator): Update generation to use new boolean name

* test(luthor): Update tests
  • Loading branch information
exaby73 authored Dec 24, 2024
1 parent 1e2e4d6 commit 3a1300a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/luthor/lib/src/validator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Validator {
}

/// Validates that the value is a bool.
Validator bool({String? message}) {
Validator boolean({String? message}) {
validations.add(BoolValidation(message: message));
return this;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/luthor/test/validations/any_validation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void main() {
});

test('should return false if the value is null with required()', () {
final result = l.bool().required().validateValue(null);
final result = l.boolean().required().validateValue(null);

switch (result) {
case SingleValidationSuccess(data: _):
Expand Down
6 changes: 3 additions & 3 deletions packages/luthor/test/validations/bool_validation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:test/test.dart';

void main() {
test('should return true when value is a valid bool', () {
final result = l.bool().validateValue(true);
final result = l.boolean().validateValue(true);

switch (result) {
case SingleValidationSuccess(data: _):
Expand All @@ -14,7 +14,7 @@ void main() {
});

test('should return false when value is not a valid bool', () {
final result = l.bool().validateValue('user');
final result = l.boolean().validateValue('user');

switch (result) {
case SingleValidationSuccess(data: _):
Expand All @@ -25,7 +25,7 @@ void main() {
});

test('should return false if the value is null with required()', () {
final result = l.required().bool().validateValue(null);
final result = l.required().boolean().validateValue(null);

switch (result) {
case SingleValidationSuccess(data: _):
Expand Down
2 changes: 1 addition & 1 deletion packages/luthor_generator/example/lib/sample.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ String getValidations(ParameterElement param) {
}

if (param.type.isDartCoreBool) {
buffer.write('l.bool()');
buffer.write('l.boolean()');
}

if (param.type.isDartCoreDouble) {
Expand Down Expand Up @@ -82,8 +82,7 @@ void _checkAndAddCustomSchema(StringBuffer buffer, ParameterElement param) {
'does not have @luthor annotation.',
);
}
buffer
.write('\$${param.type.getDisplayString()}Schema');
buffer.write('\$${param.type.getDisplayString()}Schema');
}

DartObject? getAnnotation(TypeChecker checker, Element field) {
Expand Down
2 changes: 1 addition & 1 deletion packages/luthor_generator/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:
freezed_annotation: ^2.4.3
json_annotation: ^4.8.1
luthor: ^0.4.4
source_gen: ^2.0.0
source_gen: ^1.5.0

dev_dependencies:
lint: ^2.3.0
Expand Down

0 comments on commit 3a1300a

Please sign in to comment.