{"id":19975472,"url":"https://github.com/innoave/valid","last_synced_at":"2025-05-04T02:33:55.130Z","repository":{"id":50364551,"uuid":"204534913","full_name":"innoave/valid","owner":"innoave","description":"composable validation functions for custom types","archived":false,"fork":false,"pushed_at":"2021-09-05T07:09:42.000Z","size":125,"stargazers_count":14,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-09T01:41:48.205Z","etag":null,"topics":["business-rules","composable","composition","constraints","custom-types","validate","validation"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/innoave.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-26T18:18:13.000Z","updated_at":"2024-03-29T19:08:42.000Z","dependencies_parsed_at":"2022-08-30T16:10:19.701Z","dependency_job_id":null,"html_url":"https://github.com/innoave/valid","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innoave%2Fvalid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innoave%2Fvalid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innoave%2Fvalid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innoave%2Fvalid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/innoave","download_url":"https://codeload.github.com/innoave/valid/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224380306,"owners_count":17301608,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["business-rules","composable","composition","constraints","custom-types","validate","validation"],"created_at":"2024-11-13T03:18:34.638Z","updated_at":"2024-11-13T03:18:35.249Z","avatar_url":"https://github.com/innoave.png","language":"Rust","readme":"# valid\n \n[![Latest Release]][crates.io]\n[![Documentation]][docs.rs]\n[![License]](LICENSE)\n[![Build Status]][actions]\n[![Test Coverage]][codecov]\n[![Rustc Version 1.39+]][Rust 1.39]\n\n[Latest Release]: https://img.shields.io/crates/v/valid.svg\n[Documentation]: https://docs.rs/valid/badge.svg\n[License]: https://img.shields.io/badge/license-MIT%2FApache_2.0-blue.svg\n[Build Status]: https://img.shields.io/github/workflow/status/innoave/valid/CI/master\n[Test Coverage]: https://codecov.io/gh/innoave/valid/branch/master/graph/badge.svg\n[Rustc Version 1.39+]: https://img.shields.io/badge/rustc-1.39+-lightgray.svg\n\n[crates.io]: https://crates.io/crates/valid/\n[docs.rs]: https://docs.rs/valid\n[MIT]: https://opensource.org/licenses/MIT\n[Apache-2.0]: https://www.apache.org/licenses/LICENSE-2.0\n[actions]: https://github.com/innoave/valid/actions?query=branch%3Amaster\n[codecov]: https://codecov.io/github/innoave/valid?branch=master\n[Rust 1.39]: https://blog.rust-lang.org/2019/11/07/Rust-1.39.0.html\n\n**Let the business logic only accept valid values!**\n\n* Validate custom types by composing primitive validation functions.\n\n* Use one common API for validating all kind of business rules including aspects of the application \n  state.\n\n* One common error type for all kind of constraint validations. It is designed to help with error\n  messages that are meaningful to the user of an application. \n\n`valid` is a validation library for the [Rust] language. It let us write validation functions for\nour custom types through composition of available validators. Any custom written validation function\nagain can be used to build validations for even more complex types.\n\nThe `valid` crate defines the types and traits to implement validation functions and use them to\nvalidate our values. Additionally, it defines primitive constraints.\n \nMost primitive constraints validate one property of the validated type. E.g. the `Length` constraint\nvalidates the length property of strings, container types or slices. If the constraint property is\nnot covered by a trait of the std-lib, a related trait is defined, which we call a _property trait_. \n\nThe builtin constraints are implemented for generic types `T` that implement the related property\ntrait.\n\nOne goal of `valid` is to provide one common API that can be used to validate all kind of business \nrules. Constraints are grouped into one of 3 categories:\n \n1. field level constraint, e.g. only a range of values is allowed\n2. the relation of 2 fields, e.g. 2 password fields must match or 2 fields must define a range\n3. business rules that verify some aspect of the application state, e.g. a username must be unique\n\nAny violation of constraints are returned in one common error type, regardless of the category of \nthe business rule that defines the constraint.\n\nOne principle for the core functionality of this crate is to have no dependencies other than\nthe std-lib. Support for types of 3rd party crates such as [`bigdecimal`] and [`chrono`] are \nimplemented as optional crate features. So you can pick and choose which types you need in your \napplication and which dependencies you will have in your project.\n\n## Features\n\n* Common validation API for validating constraints on field values, constraints on related fields \n  and constraints on application state \n* Definition of primitive constraints, such as `Length`, `CharCount`, `Bound` and `MustMatch` \n* Generic implementations of the validation function for the provided constraints\n* Composition of validation functions to implement validation for complex types\n* One common error type for validation errors of all kind of constraints\n* Accumulation of multiple constraint violations\n* Separation of the validation process itself and presentation of validation errors\n* The `ValidationError` is designed to help with composing detailed and helpful error messages\n  targeted to the users of an application. Localization or internationalization of error messages is\n  not scope of this crate.\n* The core functionality has no dependencies to 3rd party crates\n* Error codes are compatible with the naming convention in the [_fluent_] project\n* The error type `ValidationError` implements `std::error::Error` and can be used with the\n  [`failure`] crate\n* Serialization and deserialization of `ValidationError` through [`serde`] (optional crate feature\n  \"serde1\")\n* Support for widely used types of 3rd party crates through optional crate features\n* Support for `BigDecimal` of the [`bigdecimal`] crate (optional crate feature \"bigdecimal\")\n* Support for `BigInt` of the [`num-bigint`] crate (optional crate feature \"num-bigint\")\n* Support for `DateTime` and `NaiveDate` of the [`chrono`] crate (optional crate feature \"chrono\")\n\n## Usage\n \nFor detailed information on how to use [`valid`] including lots of examples see the\n[API documentation at docs.rs](https://docs.rs/valid).\n\nTo use `valid` we add it as a dependency to our `Cargo.toml` file:\n\n```toml\n[dependencies]\nvalid = \"0.3\"\n```\n\n`valid` provides some of its functionality as optional crate features. Some features enable support\nfor validating a type that is provided by this crate. Other features enable the implementation of\nadditional constraints. To use any optional functionality we must enable the relevant crate feature\nin our `Cargo.toml` file. All crate features can be enabled in any combination.\n\nHere is an overview of all crate features:\n\n| crate feature | supported types         | enabled constraints |\n|---------------|-------------------------|---------------------|\n| `bigint`      | `BigInt`                |                     |\n| `bigdecimal`  | `BigDecimal`            |                     |\n| `chrono`      | `DateTime`, `NaiveDate` |                     |\n| `regex`       |                         | `Pattern`           | \n\nAdditionally the \"serde1\" feature enables serialization and deserialization of `ValdiationError` \nusing the [`serde`] crate:\n\n```toml\n[dependencies]\nvalid = { version = \"0.3\", features = [\"serde1\"] }\n```\n\n\n[rust]: https://rust-lang.org\n[`bigdecimal`]: https://crates.io/crates/bigdecimal\n[`chrono`]: https://crates.io/crates/chrono\n[`failure`]: https://crates.io/crates/failure\n[_fluent_]: https://projectfluent.org/\n[`num-bigint`]: https://crates.io/crates/num-bigint\n[`serde`]: https://crates.io/crates/serde\n[`valid`]: https://crates.io/crates/valid\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finnoave%2Fvalid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finnoave%2Fvalid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finnoave%2Fvalid/lists"}