Skip to content

Proposal: Data integrity

Romans Malinovskis edited this page Aug 4, 2016 · 3 revisions

in old ATK we had a 'mandatory' flag that would require UI element to fail if user would leave entry empty. It has been a place of confusion, so this article is a proposal how to implement this in Agile Data:

Cases to consider:

UI framework presents a form with "name" field. User leaves field empty and hits save. Should operation be successful if "name" field is marked as mandatory?

  • AD: Well, the field was presented but was empty string, so it's OK
  • AD: If numeric value is mandatory and presented with value 0, it should be fine, right?
  • AD: Would false value of a boolean field be mandatory?
  • What if form has a mandatory checkbox and user does not click it. Is that an error?

Next set of questions says, who should do the validation:

  • AD: Loaded record from DB where mandatory field is null. Error?
  • AD: User manually created record ommitting mandatory field. Error?
  • AD: User did set the field value to "NULL" explicitly. Error?

AD vs UI vs Validator:

  • Should UI signal user about missing value?
  • Mandatory fields may contain asterisk next to label. Where UI gets information about that?

Trickier cases:

  • would empty array [] be permitted in mandatory field? (non-sql)
  • what if date is mandatory. Would 0000-00-00 be an OK value?

Proposed Implementation:

  • AD to only reject NULL for mandatory fields.
  • UI form reads $field->mandatory flag and invokes necessary validation
  • Validation framework can perform further validation (e.g. non-empty string, or non-zero)

Disagree? Willing to discuss?

Please tell us before we started implementing. Visit our Chat.