Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

validation should change on some field #19

Open
ZaynJarvis opened this issue Feb 13, 2019 · 1 comment
Open

validation should change on some field #19

ZaynJarvis opened this issue Feb 13, 2019 · 1 comment
Assignees
Labels
discussion Discuss on the topic enhancement New feature or request question Further information is requested

Comments

@ZaynJarvis
Copy link
Member

ZaynJarvis commented Feb 13, 2019

  1. React does not allow input with null values. Hence presence in react doesn't actually work.
    a walk around will be presence: { allowEmpty: false }
  2. url tag with present: false doesn't work, a walk around will be
validators.urlAllowBlank = (value: any, ...others: any[]) => {
    if (isEmpty(value)) {
        return;
    }
    return validators.url(value, ...others);
}
xxx: {
  urlAllowBlank: true,
}
  1. [ discussion ] xxxExist validation cause huge overhead
  • Formik or any other form construction library may not be able to select name from the UI but use id to transmit info at the back.
  • select options are fetched from library initially, validate the field for another time may be an overhead. And there's more boilerplate code for name -> id transformation either in frontend or backend.
@ZaynJarvis ZaynJarvis added enhancement New feature or request question Further information is requested discussion Discuss on the topic labels Feb 13, 2019
@clarencecastillo
Copy link
Member

Those are good points! Another way is to move the ID validation on the api side. Still redundant, but it is still good practice because we should not assume the client is always following the rules.

Can we selectively ignore the constraints instead? Ignore those with select ID.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
discussion Discuss on the topic enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants