### File

`projects/angular-l10n/src/lib/services/l10n-validation.ts`

### Index

###### Methods

- Public parseDate
- Public parseNumber

### Constructor

`constructor(locale: L10nLocale)`
Defined in projects/angular-l10n/src/lib/services/l10n-validation.ts:39

Parameters :

Name | Type | Optional
locale | `L10nLocale` | No

### Methods

Public parseDate
`parseDate(value: string, options?: L10nDateTimeFormatOptions, language)`
Defined in projects/angular-l10n/src/lib/services/l10n-validation.ts:51

Parameters :

Name | Type | Optional | Default value
value | `string` | No |
options | `L10nDateTimeFormatOptions` | Yes |
language |  | No | `this.locale.dateLanguage || this.locale.language`

Returns : `Date | null`

Public parseNumber
`parseNumber(value: string, options?: L10nNumberFormatOptions, language)`
Defined in projects/angular-l10n/src/lib/services/l10n-validation.ts:43

Parameters :

Name | Type | Optional | Default value
value | `string` | No |
options | `L10nNumberFormatOptions` | Yes |
language |  | No | `this.locale.numberLanguage || this.locale.language`

Returns : `number | null`

    import { Injectable, Inject } from '@angular/core';

    import { L10nNumberFormatOptions, L10nDateTimeFormatOptions, L10nLocale } from '../models/types';
    import { L10N_LOCALE } from '../models/l10n-config';

    /**
     * Implement this class-interface to create a validation service.
     */
    @Injectable() export abstract class L10nValidation {

        /**
         * This method must contain the logic to convert a string to a number.
         * @param value The string to be parsed
         * @param options A L10n or Intl NumberFormatOptions object
         * @param language The current language
         * @return The parsed number
         */
        public abstract parseNumber(
            value: string,
            options?: L10nNumberFormatOptions,
            language?: string
        ): number | null;

        /**
         * This method must contain the logic to convert a string to a date.
         * @param value The string to be parsed
         * @param options A L10n or Intl DateTimeFormatOptions object
         * @param language The current language
         * @return The parsed date
         */
        public abstract parseDate(
            value: string,
            options?: L10nDateTimeFormatOptions,
            language?: string
        ): Date | null;

    }

    @Injectable() export class L10nDefaultValidation {

        constructor(@Inject(L10N_LOCALE) private locale: L10nLocale) { }

        public parseNumber(
            value: string,
            options?: L10nNumberFormatOptions,
            language = this.locale.numberLanguage || this.locale.language
        ): number | null {
            return null;
        }

        public parseDate(
            value: string,
            options?: L10nDateTimeFormatOptions,
            language = this.locale.dateLanguage || this.locale.language
        ): Date | null {
            return null;
        }

    }

# result-matching ""

# No results matching ""