attr_masker
attr_masker copied to clipboard
Masking may make records invalid
No record should become invalid in the result of masking. The Rake task should loudly fail in the attempt of invalid record creation. Or, if it's difficult, we should at least add a clear warning to the README file.
@ronaldtse's comment:
Masking MUST make sure the record is still valid. However, it might be up to the user of the attr_masker gem to get this right, i.e. it's not the burden of attr_masker to ensure validity. I don't think it is trivial at all to make attr_masker reuse the validation rules (which can be very arbitrary) for its attribute to generate random but valid values.
In the case of masking causing bad records, it is up to the user to have done DB backups and to restore it to its valid state, and to fix up any bad masking settings before re-running db:mask.
Maybe we should make this point clear in the README, etc.