mirror of https://github.com/ghostfolio/ghostfolio
Thomas Kaul
7 months ago
committed by
GitHub
7 changed files with 60 additions and 4 deletions
@ -0,0 +1,16 @@ |
|||||
|
import { |
||||
|
ValidatorConstraint, |
||||
|
ValidatorConstraintInterface |
||||
|
} from 'class-validator'; |
||||
|
import { format, isAfter, parseISO } from 'date-fns'; |
||||
|
|
||||
|
@ValidatorConstraint({ name: 'isAfter1970' }) |
||||
|
export class IsAfter1970Constraint implements ValidatorConstraintInterface { |
||||
|
public defaultMessage() { |
||||
|
return `date must be after ${format(new Date(0), 'yyyy')}`; |
||||
|
} |
||||
|
|
||||
|
public validate(aDateString: string) { |
||||
|
return isAfter(parseISO(aDateString), new Date(0)); |
||||
|
} |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
{ |
||||
|
"meta": { |
||||
|
"date": "2021-01-01T00:00:00.000Z", |
||||
|
"version": "dev" |
||||
|
}, |
||||
|
"activities": [ |
||||
|
{ |
||||
|
"currency": "USD", |
||||
|
"dataSource": "YAHOO", |
||||
|
"date": "1960-01-01T00:00:00.000Z", |
||||
|
"fee": 0, |
||||
|
"quantity": 20, |
||||
|
"symbol": "AAPL", |
||||
|
"type": "BUY", |
||||
|
"unitPrice": 100.0 |
||||
|
} |
||||
|
] |
||||
|
} |
Loading…
Reference in new issue