tkrotoff / react-form-with-constraints

Simple form validation for React
MIT License
126 stars 20 forks source link

Returns HTMLElement in Field #41

Closed phong-steph closed 5 years ago

phong-steph commented 5 years ago

Hello @tkrotoff! Thanks for your great job :+1:

It would be appreciated if you could return in the Field object, the HTMLElement of the invalid field? Something like:

{
  name: string;
  validations: { // FieldFeedbackValidation[]
    key: number;
    type: 'error' | 'warning' | 'info' | 'whenValid';
    show: boolean | undefined;
  }[];
  isValid: () => boolean,
  element: HTMLElement
}

Thanks! ;)

tkrotoff commented 5 years ago

See https://github.com/tkrotoff/react-form-with-constraints/commit/68b078b62433ce29d465f341bdaf22c2f2ea6c04#diff-4d30728b55ab9b1ded308aa269e0b286R87