4 releases
new 0.1.3 | Jan 24, 2025 |
---|---|
0.1.2 | May 19, 2021 |
0.1.1 | Nov 20, 2020 |
0.1.0 | Oct 15, 2020 |
#500 in Web programming
111 downloads per month
33KB
836 lines
Adequate
A yet another validation library provides a macro inspired by Accord.
Repositories
This library is developed mainly on Codeberg.org, but the source code is hosted also on sourcehut.
Any patches, merge/pull requests or issues on those repositories are welcomed.
# the main branch is "trunk"
% git clone git@codeberg.org:grauwoelfchen/adequate.git
% git --no-pager branch -v
* trunk xxxxxxx XXX
Installation
% cargo install adequate
Usage
TODO: Add more detailed examples
See src/validation
directory for validators.
use adequate::validation::{contain, length};
// inputs
let fullname = "Albrecht Dürer";
let username = "albrecht";
let result = validate! {
"fullname" => fullname => [length::max(3)],
"username" => username => [
length::within(3..9),
contain::contains_only_alphanumeric_chars(),
],
};
assert!(result.is_err());
Validations
Contain
- contains
- contains_any
- contains_any_digits
- contains_any_lower_letters
- contains_any_upper_letters
- contains_only
- contains_only_alphanumeric_chars
- contains_if_present
- contains_if_given
- not_contain_if_given
Length
- max
- max_if_present
- min
- min_if_present
- within
Build
Check make help
# debug build
% make build:debug
Development
vet
# check code using all vet:xxx targets
% make vet:all
Test
% make test
# or check the report by kcov
% make coverage
CI
TODO: Use Woodpecker CI
Run CI jobs on local docker conatiner (Gentoo Linux) using gitlab-runner.
See .gitlab-ci.yml
.
# prepare environment variables for CI via .env.ci
% cp .env.ci.sample .env
# e.g. test (see .gitlab-ci.yml)
% make runner-test
Release
All notable released changes of this package will be documented in CHANGELOG file.
Unreleased commits
License
Adequate
Copyright 2020-2025 Yasha
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Dependencies
~0.4–1MB
~22K SLoC