Skip to content
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

docs(OrganizationNumber): adds docs about validation #4078

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ showTabs: true

This input expects a 9-digit number as its value. This is because Norwegian organization numbers are 9-digits long, based on info from [Brønnøysundregisteret](https://www.brreg.no/en/about-us-2/our-registers/about-the-central-coordinating-register-for-legal-entities-ccr/about-the-organisation-number/?nocache=1701776533136)
It validates input for Norwegian organization numbers, as described by [Brønnøysundregistrene](https://www.brreg.no/om-oss/registrene-vare/om-enhetsregisteret/organisasjonsnummeret/).
The validation happens on blur, internally using the `onBlurValidator` [property](/uilib/extensions/forms/feature-fields/OrganizationNumber/properties/#field-specific-properties).

```jsx
import { Field } from '@dnb/eufemia/extensions/forms'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@ showTabs: true
import TranslationsTable from 'dnb-design-system-portal/src/shared/parts/TranslationsTable'
import PropertiesTable from 'dnb-design-system-portal/src/shared/parts/PropertiesTable'
import { fieldProperties } from '@dnb/eufemia/src/extensions/forms/Field/FieldDocs'
import { OrganizationNumberProperties } from '@dnb/eufemia/src/extensions/forms/Field/OrganizationNumber/OrganizationNumberDocs'

## Properties

### Field-specific properties

| Property | Type | Description |
| ---------- | --------- | ------------------------------------------------------------------------------- |
| `validate` | `boolean` | _(optional)_ Using this property you can disable the default validation. |
| `help` | `object` | _(optional)_ Provide a help button. Object consisting of `title` and `content`. |
<PropertiesTable props={OrganizationNumberProperties} />

### General properties

<PropertiesTable props={fieldProperties} />
<PropertiesTable props={fieldProperties} omit={['onBlurValidator']} />

## Translations

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { PropertiesTableProps } from '../../../../shared/types'

export const OrganizationNumberProperties: PropertiesTableProps = {
validate: {
doc: 'Using this prop you can disable the default validation.',
type: 'boolean',
status: 'optional',
},
help: {
doc: 'Provide a help button. Object consisting of `title` and `content`.',
type: 'object',
status: 'optional',
},
onBlurValidator: {
doc: 'Custom validator function that is triggered when the user leaves a field (e.g., blurring a text input or closing a dropdown). The function can be either asynchronous or synchronous. The first parameter is the value, and the second parameter returns an object containing { errorMessages, connectWithPath, validators }. Defaults to organization number validation.',
type: 'function',
status: 'optional',
},
}
Loading