You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
requires :name, values: { value:1..10, message:'not in range from 1 to 10' }, allow_blank: { value:false, message:'cannot be blank' }, regexp: { value:/^[a-z]+$/, message:'format is invalid' }, message:'is required'
exactly_one_of :beer, :wine, :juice, message: {exactly_one:"are missing, exactly one parameter is required", mutual_exclusion:"are mutually exclusive, exactly one parameter is required"}
1582
1591
end
1583
1592
```
1593
+
1584
1594
#### `at_least_one_of`
1585
1595
1586
1596
```ruby
@@ -1591,20 +1601,23 @@ params do
1591
1601
at_least_one_of :beer, :wine, :juice, message:"are missing, please specify at least one param"
1592
1602
end
1593
1603
```
1604
+
1594
1605
#### `Coerce`
1595
1606
1596
1607
```ruby
1597
1608
params do
1598
1609
requires :int, type: {value:Integer, message:"type cast is invalid" }
1599
1610
end
1600
1611
```
1612
+
1601
1613
#### `With Lambdas`
1602
1614
1603
1615
```ruby
1604
1616
params do
1605
1617
requires :name, values: { value:-> { (1..10).to_a }, message:'not in range from 1 to 10' }
1606
1618
end
1607
1619
```
1620
+
1608
1621
#### `Pass symbols for i18n translations`
1609
1622
1610
1623
You can pass a symbol if you want i18n translations for your custom validation messages.
@@ -1652,6 +1665,7 @@ params do
1652
1665
requires :name, values: { value:-> { (1..10).to_a }, message:'not in range from 1 to 10' }, default:5
1653
1666
end
1654
1667
```
1668
+
1655
1669
## Headers
1656
1670
1657
1671
Request headers are available through the `headers` helper or from `env` in their original form.
0 commit comments