Skip to content

feat(easy-domain): add VAT with testing - #574

Merged
woutervanbakel merged 5 commits into
thisisagile:mainfrom
space-shifter:main
Dec 15, 2025
Merged

woutervanbakel merged 5 commits into
thisisagile:mainfrom
space-shifter:main

Conversation

@space-shifter

Copy link
Copy Markdown
Contributor

Using validator.js added in easy domain with testing and sanitization for easy storage

Comment thread packages/easy-domain/src/values/VAT.ts Outdated
}

get isValid(): boolean {
const shopCode = (ctx.request as any)?.shopCode;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't use request context like this in a generic library, please move the country to the construtor. Maybe optional with a default on NL. So new VAT('123', 'NL')

Comment thread packages/easy-domain/src/values/VAT.ts Outdated
}
}

export const toVAT = (vat?: unknown): VAT => new VAT(vat);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go for vat instead. Same as email and the others

@space-shifter

Copy link
Copy Markdown
Contributor Author

@woutervanbakel pushed the fixes

Comment thread packages/easy-domain/src/values/VAT.ts Outdated
export class VAT extends Value {
private readonly country: string;

constructor(vat?: unknown, country = 'NL') {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vat needs to be required.

Comment thread packages/easy-domain/src/values/VAT.ts Outdated
constructor(vat?: unknown, country = 'NL') {
const cleaned = replaceAll(text(vat).trim, '.', '');
super(cleaned.toString());
this.country = country;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

country always toUpper.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text(country).trim.upper.toString()

Comment thread packages/easy-domain/src/values/VAT.ts Outdated

constructor(vat?: unknown, country = 'NL') {
const cleaned = replaceAll(text(vat).trim, '.', '');
super(cleaned.toString());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text(vat).trim.replace('.', '').toString()

@space-shifter

Copy link
Copy Markdown
Contributor Author

@woutervanbakel fixed the above

@woutervanbakel

Copy link
Copy Markdown
Collaborator

Thanks for your addition!

@woutervanbakel
woutervanbakel merged commit 7eacc11 into thisisagile:main Dec 15, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants