New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the current row's information in the onGetErrorMessage callback #92

Closed
spplante opened this Issue Aug 22, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@spplante

spplante commented Aug 22, 2018

Category

  • Enhancement
  • Bug
  • Question

Version

1.9.0

Expected / Desired Behavior / Question

When using the onGetErrorMessage callback on a text field, it would be great to have a second parameter currentRow: any in the callback in order to give the user the possibility to do some validations based on the other fields of the current row.

For example, if I have the columns Home Phone and Cell Phone and I want to do some custom validation on the Cell Phone column, like allow empty values only is Home Phone is provided.

So instead of having the following callback :

onGetErrorMessage(value: any)

We would have something like this :

onGetErrorMessage(value: any, currentRow: any)

👍

@estruyf estruyf added the enhancement label Sep 6, 2018

@estruyf

This comment has been minimized.

Collaborator

estruyf commented Sep 6, 2018

Thanks @spplante for reporting this. I will work on this one to get it included in version 1.10.0.

@estruyf estruyf added this to the 1.10.0 milestone Sep 6, 2018

estruyf added a commit that referenced this issue Sep 6, 2018

@estruyf

This comment has been minimized.

Collaborator

estruyf commented Sep 6, 2018

I pushed a change for this to support this. The callback provides you with the current value you are editing, index of the row and the item itself with all its properties.

Here is an example of a new item:

screenshot 2018-09-06 16 30 40

Here is an example of a stored item:

screenshot 2018-09-06 16 31 15

private minLengthValidation (value: string, index: number, item: any) {
  console.log(`Currently editing item nr: ${index === null ? "new item" : index}. It contains the following properties:`, item);
  return value.length >= 3 ? "" : "Should at least contain 3 characters.";
}

If you want, you can already test out the latest 1.10.0 beta: https://sharepoint.github.io/sp-dev-fx-property-controls/beta/

@spplante

This comment has been minimized.

spplante commented Sep 6, 2018

Good stuff!

@estruyf

This comment has been minimized.

Collaborator

estruyf commented Sep 17, 2018

Closing the issue as it got released in version 1.10.0.

@estruyf estruyf closed this Sep 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment