https://github.com/kaizen-gaming/vex_validators
Vex Extra Validators
https://github.com/kaizen-gaming/vex_validators
elixir validation validator validators vex
Last synced: 3 days ago
JSON representation
Vex Extra Validators
- Host: GitHub
- URL: https://github.com/kaizen-gaming/vex_validators
- Owner: Kaizen-Gaming
- License: mit
- Created: 2017-12-06T11:25:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-23T07:09:06.000Z (over 7 years ago)
- Last Synced: 2023-12-31T01:22:18.390Z (over 2 years ago)
- Topics: elixir, validation, validator, validators, vex
- Language: Elixir
- Homepage:
- Size: 10.7 KB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Vex **Extra** Validators
**Note:** If you are using the Number and/or the UUID validators, we suggest to use instead the ones from the [Vex](https://github.com/CargoSense/vex) package as we made a [PR](https://github.com/CargoSense/vex/pull/55) and it was accepted!
[Vex](https://github.com/CargoSense/vex) is an extensible data validation library for Elixir.
This library provides new validator [modules that can be used as sources](https://github.com/CargoSense/vex#using-modules-as-sources) in Vex.
## Installation
Add `vex_validators` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:vex_validators, github: "StoiximanServices/vex_validators"}
]
end
```
Then add in your `config.exs` the following configuration to add as an additional source for Vex:
```elixir
config :vex,
sources: [VexValidators, Vex.Validators]
```
## The extra validators
Additionally to the built-in Vex validators, `vex_validators` also provides the following validators.
For more information on how to use the validators, please see the [Vex documentation](https://github.com/CargoSense/vex#supported-validations).
### Number
Ensure a value is a number equal to another:
```elixir
Vex.valid? post, [number: [==: 1]]
```
Ensure a value is a number greater than another:
```elixir
Vex.valid? post, [number: [<: 1]]
```
Ensure a value is a number less than another:
```elixir
Vex.valid? post, [number: [<: 1]]
```
This validation can be skipped for `nil` or blank values by including `allow_nil: true` and/or `allow_blank: true`.
See the documentation on `VexValidators.Number` for details on available options.
### Type
Ensure a value is of a specific Elixir type:
```elixir
Vex.valid? post, [type: :string]
```
This validation can be skipped for `nil` or blank values by including `allow_nil: true` and/or `allow_blank: true`.
See the documentation on `VexValidators.Type` for details on available options.
### UUID
Ensure a value is a valid UUID string:
```elixir
Vex.valid? post, [id: [uuid: true]]
```
To check if the value is a valid UUID of a specific format:
```elixir
Vex.valid? post, [id: [uuid: :hex]]
```
See documentation on `VexValidators.Uuid` for details on available options.