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
3 changes: 1 addition & 2 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ validgen/
│ ├── parser_validation.go # Validation tag parsing
│ └── test_elements.go # Test condition building
├── types/ # Common types and error handling
├── _examples/ # Example usage and test cases
└── tests/ # Integration, unit, and benchmark tests
```

Expand Down Expand Up @@ -157,7 +156,7 @@ Follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/
### Documentation Standards
- **Generated code comments**: Include generation warning in all generated files
- **Function documentation**: Document validation functions if exported
- **Example usage**: Provide clear examples in `_examples/` directory
- **Example usage**: Examples live in github.com/opencodeco/validgen-samples

## CLI Usage Patterns

Expand Down
53 changes: 6 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,60 +207,19 @@ cd validgen
make endtoendtests
```

## Steps to run the examples
## Examples

All examples are in the `_examples` folder.
Examples live in [opencodeco/validgen-samples](https://github.com/opencodeco/validgen-samples).

### Steps to run test01
That repository is a separate Go module. It shows the ValidGen CLI, the generated import of `github.com/opencodeco/validgen/types`, and a caller importing the package that owns the structs.

Test01 aims to be a case where all the files are in the same package (in this case, the main package).
Build the CLI from this repository with `make build`. The binary is `bin/validgen`. It takes one path and writes `validator__.go` next to the structs.

```bash
# Runs validgen to generate structs validator code
./bin/validgen _examples/test01
./bin/validgen /path/to/package
```

After that the file `user_validator.go` will be generated. This file contains UserValidate function that is responsible to check if User object has a valid content.

```bash
# Execute the test
cd _examples/test01
go run .
```

### Steps to run test02

Test02 aims to be an example where the structs to be validated are in another package (structsinpkg in this test).

```bash
# Runs validgen to generate structs validator code
./bin/validgen _examples/test02
```

After that the file `user_validator.go` will be generated. This file contains UserValidate function that is responsible to check if User object has a valid content.

```bash
# Execute the test
cd _examples/test02
go run .
```

### Steps to run test03

Test03 aims to be an example where the structs to be validated use min and max tags.

```bash
# Runs validgen to generate structs validator code
./bin/validgen _examples/test03
```

After that the file `user_validator.go` will be generated. This file contains UserValidate function that is responsible to check if User object has a valid content.

```bash
# Execute the test
cd _examples/test03
go run .
```
Pass `-unmarshal-json` to also generate `UnmarshalJSON` methods. The samples repository shows that flag on `signup`.

## Steps to run the benchmark tests comparing ValidGen and Validator

Expand Down
87 changes: 0 additions & 87 deletions _examples/email_test/test_email.go

This file was deleted.

22 changes: 0 additions & 22 deletions _examples/email_test/validator__.go

This file was deleted.

37 changes: 0 additions & 37 deletions _examples/test01/test01.go

This file was deleted.

22 changes: 0 additions & 22 deletions _examples/test01/validator__.go

This file was deleted.

12 changes: 0 additions & 12 deletions _examples/test02/structsinpkg/mystructs.go

This file was deleted.

22 changes: 0 additions & 22 deletions _examples/test02/structsinpkg/validator__.go

This file was deleted.

28 changes: 0 additions & 28 deletions _examples/test02/test02.go

This file was deleted.

54 changes: 0 additions & 54 deletions _examples/test03/test03.go

This file was deleted.

Loading
Loading