Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 165 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# GitHub Copilot Instructions for dart_validator

## Project Overview
This is a Flutter/Dart validation package called **mayr_validator**, providing a fluent API for building validations inspired by Laravel's validator syntax.

## Package Information
- **Organization**: MayR Labs (https://github.com/MayR-Labs)
- **Website**: https://mayrlabs.com
- **Repository**: https://github.com/MayR-Labs/dart_validator
- **Package Name**: mayr_validator
- **License**: MIT License, Copyright (c) 2025 MayR Labs

## Development Guidelines

### Code Style
- Follow the [Dart Style Guide](https://dart.dev/guides/language/effective-dart/style)
- Use `dart format` to format all Dart code
- Run `dart analyze` or `flutter analyze` to check for issues before committing
- Maintain consistency with existing code patterns

### Architecture
- **Core Singleton Pattern**: `MayrValidationCore` handles global configuration
- **Fluent API**: `MayrValidator` provides chainable validation methods
- **Extension Methods**: Enable elegant syntax like `value.mayrValidator()`
- **Separation of Concerns**: Keep validators, core logic, and extensions separate

### Testing
- Write comprehensive tests for all validation rules
- Use descriptive test names that explain what is being tested
- Follow the existing test structure with `group()` and `test()` blocks
- Aim for high test coverage
- Run tests with `flutter test` or `dart test`

### Adding New Validators
When adding a new validation rule:

1. **Add the method to `MayrValidator` class** in `lib/src/validators/`
2. **Include dartdoc comments** explaining the validator's purpose and parameters
3. **Add comprehensive tests** covering valid and invalid cases
4. **Update documentation**:
- Add to README.md in the appropriate category
- Update API.md if it exists
- Add entry to CHANGELOG.md
5. **Support message templating** with placeholders like `{min}`, `{max}`, `{value}`

### Flutter Integration
- Ensure validators work seamlessly with `TextFormField`
- Support both pure Dart and Flutter contexts
- Test validators in Flutter example app when adding UI-related validation

### Error Messages
- Provide clear, user-friendly error messages
- Support message customization through parameters
- Use global message configuration when available
- Include placeholders for dynamic values

### Custom Rules and Groups
- Support custom rule registration via `MayrValidationCore().registerRule()`
- Support validation groups via `MayrValidationCore().registerGroup()`
- Handle environment-aware behavior (dev vs production)

### Dependencies
- Keep dependencies minimal
- Avoid adding unnecessary external packages
- Only use well-maintained packages with good pub.dev scores
- Update dependencies carefully and test thoroughly

### Documentation
- Write clear dartdoc comments for all public APIs
- Include code examples in documentation
- Keep README.md up to date with new features
- Maintain CHANGELOG.md following semantic versioning
- Update CONTRIBUTING.md when changing development workflows

### Commit Messages
- Use clear, descriptive commit messages
- Follow conventional commit format when possible
- Reference issue numbers when applicable

### Pull Requests
- Ensure all tests pass before submitting
- Run formatter and analyzer
- Update documentation as needed
- Provide clear description of changes
- Link to related issues

### CI/CD
- All PRs must pass CI checks (tests, formatting, analysis)
- CI runs on GitHub Actions
- Workflow file: `.github/workflows/ci.yaml`

## Common Patterns

### Validator Method Template
```dart
/// [Description of what this validates]
///
/// [Optional: Additional details, examples, or constraints]
///
/// Example:
/// ```dart
/// MayrValidator('value').ruleName().run();
/// ```
MayrValidator ruleName([String? customMessage]) {
_rules.add(() {
if (value == null) return null;

// Validation logic
if (/* validation fails */) {
return customMessage ??
_core.getMessage('ruleName') ??
'Default error message';
}
return null;
});
return this;
}
```

### Test Template
```dart
group('ruleName', () {
test('should return null for valid values', () {
expect(MayrValidator('valid').ruleName().run(), isNull);
});

test('should return error message for invalid values', () {
final error = MayrValidator('invalid').ruleName().run();
expect(error, isNotNull);
expect(error, contains('expected text'));
});

test('should accept custom error message', () {
const customMessage = 'Custom error';
final error = MayrValidator('invalid').ruleName(customMessage).run();
expect(error, equals(customMessage));
});
});
```

## Package Structure
```
dart_validator/
├── lib/
│ ├── src/
│ │ ├── core/ # MayrValidationCore singleton
│ │ ├── validators/ # MayrValidator class
│ │ └── extensions/ # Extension methods
│ └── mayr_validator.dart # Main library export
├── test/ # Test files
├── example/
│ ├── mayr_validator_example.dart
│ └── flutter_example/ # Flutter example app
├── .github/
│ └── workflows/ # CI/CD workflows
└── docs/ # Additional documentation
```

## Important Notes
- Always maintain backward compatibility when possible
- Follow semantic versioning for releases
- Keep the API fluent and chainable
- Ensure validators work in both Dart and Flutter contexts
- Support null safety throughout the codebase
- Test validators with various input types (null, empty, edge cases)
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ⚡ **Debounce Support** - Control when validations run
- 🧍‍♂️ **Standalone or Flutter-ready** - Works in pure Dart and Flutter

[1.0.0]: https://github.com/YoungMayor/mayr_dart_validator/releases/tag/v1.0.0
[1.0.0]: https://github.com/MayR-Labs/dart_validator/releases/tag/v1.0.0

14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Thank you for your interest in contributing to MayrValidations! We welcome contr

If you find a bug or have a feature request:

1. Check if the issue already exists in [GitHub Issues](https://github.com/YoungMayor/mayr_dart_validator/issues)
1. Check if the issue already exists in [GitHub Issues](https://github.com/MayR-Labs/dart_validator/issues)
2. If not, create a new issue with:
- Clear title and description
- Steps to reproduce (for bugs)
Expand All @@ -22,8 +22,8 @@ We love pull requests! Here's how to contribute code:

1. **Fork the repository**
```bash
git clone https://github.com/YOUR_USERNAME/mayr_dart_validator.git
cd mayr_dart_validator
git clone https://github.com/YOUR_USERNAME/dart_validator.git
cd dart_validator
```

2. **Create a feature branch**
Expand Down Expand Up @@ -101,7 +101,7 @@ group('Feature Name', () {
## 🏗️ Project Structure

```
mayr_dart_validator/
dart_validator/
├── lib/
│ ├── src/
│ │ ├── core/ # Core singleton and configuration
Expand Down Expand Up @@ -183,9 +183,9 @@ By contributing, you agree that your contributions will be licensed under the MI

If you have questions:

- Open a [GitHub Discussion](https://github.com/YoungMayor/mayr_dart_validator/discussions)
- Check existing [Issues](https://github.com/YoungMayor/mayr_dart_validator/issues)
- Read the [Documentation](https://github.com/YoungMayor/mayr_dart_validator)
- Open a [GitHub Discussion](https://github.com/MayR-Labs/dart_validator/discussions)
- Check existing [Issues](https://github.com/MayR-Labs/dart_validator/issues)
- Read the [Documentation](https://github.com/MayR-Labs/dart_validator)

## 👥 Code of Conduct

Expand Down
2 changes: 1 addition & 1 deletion IMPLEMENTATION_SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ MayrValidationCore().registerGroup('username', (validator, params) {
- **Name**: mayr_validator
- **Version**: 1.0.0
- **Description**: A powerful yet elegant validation library for Dart and Flutter
- **Author**: Meyoron Aghogho (MayR Labs)
- **Organization**: MayR Labs (https://github.com/MayR-Labs)
- **License**: MIT
- **SDK**: Dart ^3.9.2
- **Dependencies**: None (pure Dart)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2025 Meyoron Aghogho
Copyright (c) 2025 MayR Labs (https://mayrlabs.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
![Pub.dev Publisher](https://img.shields.io/pub/publisher/mayr_validator?label=Publisher&style=plastic)
![Downloads](https://img.shields.io/pub/dm/mayr_validator.svg?label=Downloads&style=plastic)

![Build Status](https://img.shields.io/github/actions/workflow/status/YoungMayor/mayr_dart_validator/ci.yaml?label=Build)
![Issues](https://img.shields.io/github/issues/YoungMayor/mayr_dart_validator.svg?label=Issues)
![Last Commit](https://img.shields.io/github/last-commit/YoungMayor/mayr_dart_validator.svg?label=Latest%20Commit)
![Contributors](https://img.shields.io/github/contributors/YoungMayor/mayr_dart_validator.svg?label=Contributors)
![Build Status](https://img.shields.io/github/actions/workflow/status/MayR-Labs/dart_validator/ci.yaml?label=Build)
![Issues](https://img.shields.io/github/issues/MayR-Labs/dart_validator.svg?label=Issues)
![Last Commit](https://img.shields.io/github/last-commit/MayR-Labs/dart_validator.svg?label=Latest%20Commit)
![Contributors](https://img.shields.io/github/contributors/MayR-Labs/dart_validator.svg?label=Contributors)


# 🧠 MayrValidations
Expand All @@ -36,14 +36,14 @@ It provides a fluent API to build validations that are **expressive**, **chainab
Add to your project:

```bash
dart pub add mayr_validations
dart pub add mayr_validator
```

Or in `pubspec.yaml`:

```yaml
dependencies:
mayr_validations: ^1.0.0
mayr_validator: ^1.0.0
```

---
Expand Down Expand Up @@ -526,7 +526,7 @@ This package is licensed under the MIT License — which means you are free to u

> See the [LICENSE](LICENSE) file for more details.

MIT © 2025 [MayR Labs](https://github.com/mayrlabs)
MIT © 2025 [MayR Labs](https://github.com/MayR-Labs)

---

Expand Down
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: mayr_validator
description: A powerful yet elegant validation library for Dart and Flutter, inspired by Laravel's validator syntax and philosophy.
version: 1.0.0
homepage: https://github.com/YoungMayor/mayr_dart_validator
repository: https://github.com/YoungMayor/mayr_dart_validator
issue_tracker: https://github.com/YoungMayor/mayr_dart_validator/issues
documentation: https://github.com/YoungMayor/mayr_dart_validator/wiki
homepage: https://github.com/MayR-Labs/dart_validator
repository: https://github.com/MayR-Labs/dart_validator
issue_tracker: https://github.com/MayR-Labs/dart_validator/issues
documentation: https://github.com/MayR-Labs/dart_validator/wiki
LICENSE: MIT

environment:
Expand Down