-
-
Notifications
You must be signed in to change notification settings - Fork 88
Way to validate group? #1158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think that the easiest way would be to have two groups.
1. Your current group
2. The rest of your fields in a different group
Then use ‘skip’ to skip everything that’s not in that group.
But, I am working now in vest v6 and I’m looking into overhauling group
validity
…On Thu, 27 Feb 2025 at 15:24 Eugene ***@***.***> wrote:
Hi! Is it possible to validate all group?
For example
import { create, test, each, enforce, group } from 'vest';
/*
data.fields = [
{
name: 'GameBoy Color',
price: 200,
id: "gb-color"
},
{
name: 'GameBoy Advance',
price: 300,
id: "gb-advance"
},
{
name: 'Nintendo 64',
price: 400,
id: "n64"
},
]
*/
const suite = create((data = {}) => {
group("myAwesomeGroup", () => {
each(data.fields, field => {
test(
field.name,
"item price must be greater than 0",
() => { enforce(field.price).isNumeric().greaterThan(0)},
field.id,
)
})
})
})
and after it call something like suit.validate("myAwesomeGroup")
—
Reply to this email directly, view it on GitHub
<#1158>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACV32P2BJUK3EAW3O72EZYL2R4GZTAVCNFSM6AAAAABX72JWHGVHI2DSMVQWIX3LMV43ASLTON2WKOZSHA4DINJRHE3TMMI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
[image: heohex]*heohex* created an issue (ealush/vest#1158)
<#1158>
Hi! Is it possible to validate all group?
For example
import { create, test, each, enforce, group } from 'vest';
/*
data.fields = [
{
name: 'GameBoy Color',
price: 200,
id: "gb-color"
},
{
name: 'GameBoy Advance',
price: 300,
id: "gb-advance"
},
{
name: 'Nintendo 64',
price: 400,
id: "n64"
},
]
*/
const suite = create((data = {}) => {
group("myAwesomeGroup", () => {
each(data.fields, field => {
test(
field.name,
"item price must be greater than 0",
() => { enforce(field.price).isNumeric().greaterThan(0)},
field.id,
)
})
})
})
and after it call something like suit.validate("myAwesomeGroup")
—
Reply to this email directly, view it on GitHub
<#1158>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACV32P2BJUK3EAW3O72EZYL2R4GZTAVCNFSM6AAAAABX72JWHGVHI2DSMVQWIX3LMV43ASLTON2WKOZSHA4DINJRHE3TMMI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
@ealush Thanks a lot! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! Is it possible to validate all group?
For example
and after it call something like
suit.validate("myAwesomeGroup")
The text was updated successfully, but these errors were encountered: