如何设置mobno字段中的位数限制(例如-10)?

时间:2017-02-17 20:49:20

标签: mongoose-schema

mobno:     {       类型:数字,       要求:是的,       分钟:10,       最大值:10,       独特:真实     }, 当我使用当前架构时,我在尝试插入新数据时会收到验证错误。我知道这种设置数字限制的方法是不正确的,但我无法在网上找到任何关于它的信息。在此先感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

试试这个:

    package com.hfad.workout;

    import android.os.Bundle;

        import android.view.LayoutInflater;
        import android.view.View;
        import android.view.ViewGroup;
        import android.widget.TextView;
        import android.support.v4.app.FragmentTransaction;
        import android.app.Fragment;

        public class WorkoutDetailFragment extends Fragment {
            private long workoutId;

            @Override
            public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
            {
                if(savedInstanceState != null)
                {
                    workoutId = savedInstanceState.getLong("workoutId");
                }
                android.support.v4.app.FragmentTransaction ft = getChildFragmentManager().beginTransaction();
                StopwatchFragment stopwatchFragment = new StopwatchFragment();
                ft.replace(R.id.stopwatch_container, stopwatchFragment);
                ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
                ft.commit();
                return inflater.inflate(R.layout.fragment_workout_detail, container, false);
            }
         }

来源:http://mongoosejs.com/docs/validation.html