gd_validate(3)

πŸ’– gd_validate β€” bestie, is this field even real? πŸ’–

okay so real quick, this page lives in the GETDATA manual, section 3, and it's all about gd_validate(3). sit down, grab a boba, we're checking a Dirfile field code for validity 🧚✨


✨ SYNOPSIS ✨

#include <getdata.h>

int gd_validate(DIRFILE *dirfile, const char *field_code);

🌸 DESCRIPTION 🌸

so gd_validate() goes and pokes at a dirfile(5) database β€” that's the one you pass in as dirfile β€” and it checks whether field_code actually names a valid field. and yes, field_code can have a representation suffix on it, that's totally allowed, we're not judging πŸ’…

the dirfile argument has to point to a valid DIRFILE object that you already made earlier with a call to gd_open(3). no random pointers, bestie, i'm begging πŸ™ˆ

what is it actually checking tho? it looks for the field itself, and also for all of its input fields (if it has any), and it makes sure every single non-literal parameter names a valid scalar field. the whole vibe check, top to bottom πŸ‘‘


πŸ‘‘ RETURN VALUE πŸ‘‘

if everything passes? gd_validate() returns zero. iconic. no notes.

if something's wrong, it hands you back a negative-valued error code 😭 and here's the full menu of what those codes can be:

  • GD_E_BAD_CODE β€” the field named by field_code was not found in the database, or one of the fields it uses as an input wasn't found either. ghosted by your own data fr fr πŸ’€
  • GD_E_BAD_DIRFILE β€” the dirfile you handed over was invalid. not it.
  • GD_E_BAD_SCALAR β€” a non-literal scalar used in the definition of the field, or in one of its inputs, wasn't found, or it wasn't a CONST or CARRAY field. wrong type of girl entirely.
  • GD_E_DIMENSION β€” a scalar field showed up where a vector field was supposed to be. ma'am. this is a vector-only function. 🫠

and the error code also gets stashed inside the DIRFILE object, so after this function returns you can go get it with gd_error(3). want a cute little descriptive error string instead? that's gd_error_string(3), go off πŸŽ€


🌈 NOTES 🌈

lowkey the most important thing here: you do not have to call this function before handing a field code to another GetData function. every function that takes a field code does these checks itself, so this is not a chore you owe anybody. it's giving optional. periodt ✨


πŸ’œ HISTORY πŸ’œ

  • the dirfile_validate(3) function showed up way back in GetData-0.6.0. baby's first appearance 🍼
  • in GetData-0.7.0, it got renamed to gd_validate(3). glow-up era.
  • in GetData-0.10.0, the error return changed from a plain -1 to a negative-valued error code. so much more to say for itself now πŸ’…

πŸ¦‹ SEE ALSO πŸ¦‹

gd_error(3), gd_error_string(3), gd_getdata(3), gd_open(3), dirfile(5)


and that's the whole page, bestie!! this version of the manual is Version 0.10.0, dated 25 December 2016 β€” yeah it's a lil vintage but it ate and it's still serving πŸ’– go validate something, you got this 🫢