wwaites / saved_fisdat

SAVED project - data processing tools for fish farms
3 stars 0 forks source link

date validator #3

Open TrondurT opened 5 months ago

TrondurT commented 5 months ago

the date validator validates everything:/ test script in link /manual_test

wwaites commented 4 months ago

huh. the entire reason i used csvwlib was to try to get a date validator without having to write one from scratch...

wwaites commented 4 months ago

first problem: the TypeConverter wants the info not as rdflib.Term but as strings in a dictionary...

second problem: the TypeConverter completely ignores the format and does not actually validate anything! Once the first problem is fixed, here,

https://github.com/DerwenAI/csvwlib/blob/d39d5be394ed97d2b4843727a63b38487243621e/csvwlib/utils/TypeConverter.py#L18

datatype looks like {'base': 'date', 'format': 'dd/MM/yyyy'} but all that gets used is the 'date' part and the format is ignored. Furthermore, no error is raised.

I wanted to use a library for this because the csvw specification for dates is weird (e.g. has nothing to do with the standard formats).

At this point, since the csvwlib library is no help, we may as well just not check dates until we have a validator that actually validates.

wwaites commented 4 months ago

A better strategy will be to bite the bullet and construct a dateutil.parser.