Skip to content

Commit

Permalink
fix: required input is correctly parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
stumpam committed Feb 27, 2022
1 parent 0933265 commit f54726b
Show file tree
Hide file tree
Showing 5 changed files with 298 additions and 596 deletions.
2 changes: 1 addition & 1 deletion libs/ngx-cz-id/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@stumpam/ngx-cz-id",
"license": "MIT",
"version": "3.0.2",
"version": "3.0.3",
"description": "Angular input for czech id (Rodné číslo) with validation.",
"homepage": "https://github.com/stumpam/ngx-cz-id",
"author": "Martin Štumpa (https://github.com/stumpam)",
Expand Down
13 changes: 10 additions & 3 deletions libs/ngx-cz-id/src/lib/directives/input/input.directive.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { BooleanInput, coerceBooleanProperty } from '@angular/cdk/coercion';
import {
ChangeDetectorRef,
Directive,
Expand Down Expand Up @@ -41,11 +42,9 @@ const nextYear = new Date().getFullYear() - 1999;

@Directive({
selector: '[ngxCzId]',
// tslint:disable-next-line: no-host-metadata-property
host: {
'(blur)': 'onBlur()',
'(input)': 'onInput($event.target.value)',
'[class.ngx-date-input]': 'true',
},
providers: [ID_VALUE_ACCESSOR, ID_VALUE_VALIDATOR],
})
Expand All @@ -55,14 +54,22 @@ export class IdInputDirective
@Input() min: number | undefined;
@Input() max: number | undefined;
@Input() options: CzIdOptions;
@Input() required: boolean;
/**
* Validation uses your RegExp and min/max validation for age.
* Validation for correctness of ID (Rodné číslo) is turned off,
* when exceptions are set.
*/
@Input() exception?: RegExp;

@Input()
get required(): boolean {
return this.#required;
}
set required(search: BooleanInput) {
this.#required = coerceBooleanProperty(search);
}
#required = false;

touchedFn: any = null;
changeFn: any = null;
disabled = false;
Expand Down
3 changes: 2 additions & 1 deletion libs/ngx-cz-id/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"enableResourceInlining": true,
"compilationMode": "partial"
"compilationMode": "partial",
"strictTemplates": true
},
"exclude": ["src/test-setup.ts", "**/*.spec.ts", "**/*.test.ts"],
"include": ["**\\*.ts"]
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"private": true,
"dependencies": {
"@angular/animations": "13.2.3",
"@angular/cdk": "^13.2.4",
"@angular/common": "13.2.3",
"@angular/compiler": "13.2.3",
"@angular/core": "13.2.3",
Expand Down
Loading

0 comments on commit f54726b

Please sign in to comment.