# Check within struct building

**URL:** https://discourse.julialang.org/t/check-within-struct-building/34522
**Category:** General Usage
**Created:** [February 12, 2020, 3:46pm UTC](https://discourse.julialang.org/t/check-within-struct-building/34522 "2020-02-12T15:46:17Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![virgile-baudrot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/virgile-baudrot/32/6857_2.png) [@virgile-baudrot](https://discourse.julialang.org/u/virgile-baudrot)
#### Post date: [February 12, 2020, 3:46pm UTC](https://discourse.julialang.org/t/check-within-struct-building/34522/1 "2020-02-12T15:46:17Z")

</div>

How to add a check between elements of a structure?

For instance, how this example couold work?

```julia
struct paramChecked
  a::Real
  b::Real
  if(a>b)
    error("a > b")
  end
end

```

Thanks

---

<div class="post-metadata">

### Author: ![daniel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daniel/32/6480_2.png) [@daniel](https://discourse.julialang.org/u/daniel)
#### Post date: [February 12, 2020, 3:54pm UTC](https://discourse.julialang.org/t/check-within-struct-building/34522/2 "2020-02-12T15:54:45Z")

</div>

here is the relevant section of the manual: [Constructors · The Julia Language](https://docs.julialang.org/en/v1/manual/constructors/#Inner-Constructor-Methods-1)

---

<div class="post-metadata">

### Author: ![virgile-baudrot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/virgile-baudrot/32/6857_2.png) [@virgile-baudrot](https://discourse.julialang.org/u/virgile-baudrot)
#### Post date: [February 13, 2020, 8:36am UTC](https://discourse.julialang.org/t/check-within-struct-building/34522/3 "2020-02-13T08:36:30Z")

</div>

Thank you.  
I’v already seen it but was not able to reuse it with several variable ; but now ok, so here is the minimal example I needed:

```julia
struct paramChecked
           a::Real
           b::Real
           c::Real
           d::Real
           e::Real
           paramChecked(a,b,c,d,e) = a > b || c < d ? error("out of order") : new(a,b,c,d,e)
end

```
