Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions content/docs/guides/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ Alongside the VineJS helpers, you may also use the `vine.helpers` object to acce
- `isLatLong`
- `isMobilePhone`
- `isPassportNumber`
- `isVAT`
- `isPostalCode`
- `isSlug`
- `isDecimal`
Expand Down
26 changes: 26 additions & 0 deletions content/docs/types/string.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const messages = {
mobile: 'The {{ field }} field must be a valid mobile phone number',
passport: 'The {{ field }} field must be a valid passport number',
postalCode: 'The {{ field }} field must be a valid postal code',
vat: 'The {{ field }} field must be a valid VAT number',
}

vine.messagesProvider = new SimpleMessagesProvider(messages)
Expand Down Expand Up @@ -561,6 +562,31 @@ vine.object({
})
```

### vat
Ensure the field's value is formatted as a valid VAT number for a given or multiple country codes.

```ts
vine.object({
vat_number: vine
.string()
.vat({ countryCode: ['IN'] })
})
```

You may define a callback function to compute the options at runtime.

```ts
vine.object({
vat_number: vine
.string()
.vat((field) => {
return {
countryCode: [field.parent.country_code]
}
})
})
```

## Mutations

Following is the list of mutations you can apply to a string value. As the name suggests, mutations normalize or change the input value and do not perform any validations.
Expand Down