Skip to content

Validating an Int value

import 'package:luthor/luthor.dart';
void main() {
final validator = l.int();
print(validator.validateValue(42));
}
import 'package:luthor/luthor.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'int_schema.freezed.dart';
part 'int_schema.g.dart';
@freezed
@luthor
class IntSchema extends _$IntSchema {
const factory IntSchema({
required int value,
}) = _$IntSchema;
static SchemaValidationResult<IntSchema> validate(
Map<String, dynamic> json,
) =>
_$IntSchemaValidate(json);
factory IntSchema.fromJson(Map<String, dynamic> json) =>
_$IntSchemaFromJson(json);
}
void main() {
print(IntSchema.validate({'value': 42}));
}