Skip to content

Commit

Permalink
docs(OrganizationNumber): adds docs about validation (#4078)
Browse files Browse the repository at this point in the history
  • Loading branch information
langz authored Oct 8, 2024
1 parent fb363d0 commit c785c51
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
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',
},
}

0 comments on commit c785c51

Please sign in to comment.