Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
essenciary committed Oct 3, 2022
1 parent 33012e1 commit f3fe1b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/FileTemplates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,19 @@ function newvalidator(validator_name::String; pluralize::Bool = true) :: String
using SearchLight, SearchLight.Validation
function not_empty(field::Symbol, m::T, args::Vararg{Any})::ValidationResult where {T<:AbstractModel}
function not_empty(field::Symbol, m::T)::ValidationResult where {T<:AbstractModel}
isempty(getfield(m, field)) && return ValidationResult(invalid, :not_empty, "should not be empty")
ValidationResult(valid)
end
function is_int(field::Symbol, m::T, args::Vararg{Any})::ValidationResult where {T<:AbstractModel}
function is_int(field::Symbol, m::T)::ValidationResult where {T<:AbstractModel}
isa(getfield(m, field), Int) || return ValidationResult(invalid, :is_int, "should be an int")
ValidationResult(valid)
end
function is_unique(field::Symbol, m::T, args::Vararg{Any})::ValidationResult where {T<:AbstractModel}
function is_unique(field::Symbol, m::T)::ValidationResult where {T<:AbstractModel}
obj = findone(typeof(m); NamedTuple(field => getfield(m, field))... )
if ( obj !== nothing && ! ispersisted(m) )
return ValidationResult(invalid, :is_unique, "already exists")
Expand Down
10 changes: 5 additions & 5 deletions src/Validation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ Creates Validation rule for a Model's field
# Examples
```julia
julia> function not_empty(field::Symbol, m::T, args::Vararg{Any})::ValidationResult where {T<:AbstractModel}
julia> function not_empty(field::Symbol, m::T)::ValidationResult where {T<:AbstractModel}
isempty(getfield(m, field)) && return ValidationResult(invalid, :not_empty, "should not be empty")
ValidationResult(valid)
end
julia> function is_int(field::Symbol, m::T, args::Vararg{Any})::ValidationResult where {T<:AbstractModel}
julia> function is_int(field::Symbol, m::T)::ValidationResult where {T<:AbstractModel}
isa(getfield(m, field), Int) || return ValidationResult(invalid, :is_int, "should be an int")
ValidationResult(valid)
end
julia> function is_unique(field::Symbol, m::T, args::Vararg{Any})::ValidationResult where {T<:AbstractModel}
julia> function is_unique(field::Symbol, m::T)::ValidationResult where {T<:AbstractModel}
obj = findone(typeof(m); NamedTuple(field => getfield(m, field))... )
if ( obj !== nothing && ! ispersisted(m) )
return ValidationResult(invalid, :is_unique, "already exists")
Expand Down

2 comments on commit f3fe1b7

@essenciary
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/69459

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.8.0 -m "<description of version>" f3fe1b7afca58305faf7579344ac8a4eb0dc578d
git push origin v2.8.0

Please sign in to comment.