Skip to content

Commit

Permalink
refactor: rename ifAny rule names
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Mar 13, 2024
1 parent 718685d commit cc629d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/schema/base/literal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class OptionalModifier<Schema extends BaseModifiersType<any, any>> extends BaseM
* one of the other fields are present with non-nullable
* value.
*/
requiredIfExistsAny(fields: string[]) {
requiredIfAnyExists(fields: string[]) {
return this.use(
requiredWhen((field) => {
return fields.some((otherField) =>
Expand Down Expand Up @@ -295,7 +295,7 @@ class OptionalModifier<Schema extends BaseModifiersType<any, any>> extends BaseM
* Mark the field under validation as required when any
* one of the other fields are missing.
*/
requiredIfMissingAny(fields: string[]) {
requiredIfAnyMissing(fields: string[]) {
return this.use(
requiredWhen((field) => {
return fields.some((otherField) =>
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/schema/conditional_required.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ test.group('requiredIfExists', () => {
})
})

test.group('requiredIfExistsAny', () => {
test.group('requiredIfAnyExists', () => {
test('fail if value is missing and any one of the other field is present', async ({ assert }) => {
const schema = vine.object({
email: vine.string().optional(),
username: vine.string().optional(),
password: vine.string().optional().requiredIfExistsAny(['email', 'username']),
password: vine.string().optional().requiredIfAnyExists(['email', 'username']),
})

const data = {
Expand All @@ -119,7 +119,7 @@ test.group('requiredIfExistsAny', () => {
const schema = vine.object({
email: vine.string().optional(),
username: vine.string().optional(),
password: vine.string().optional().requiredIfExistsAny(['email', 'username']),
password: vine.string().optional().requiredIfAnyExists(['email', 'username']),
})

const data = {
Expand Down Expand Up @@ -219,12 +219,12 @@ test.group('requiredIfMissing', () => {
})
})

test.group('requiredIfMissingAny', () => {
test.group('requiredIfAnyMissing', () => {
test('fail if value is missing and any one of the other field is missing', async ({ assert }) => {
const schema = vine.object({
email: vine.string().optional(),
username: vine.string().optional(),
githubId: vine.string().optional().requiredIfMissingAny(['email', 'username']),
githubId: vine.string().optional().requiredIfAnyMissing(['email', 'username']),
})

const data = {
Expand All @@ -244,7 +244,7 @@ test.group('requiredIfMissingAny', () => {
const schema = vine.object({
email: vine.string().optional(),
username: vine.string().optional(),
githubId: vine.string().optional().requiredIfMissingAny(['email', 'username']),
githubId: vine.string().optional().requiredIfAnyMissing(['email', 'username']),
})

const data = {
Expand Down

0 comments on commit cc629d8

Please sign in to comment.